# Discourse Theme CLI errors with pnpm installed node\_modules due to symlinks

**URL:** https://meta.discourse.org/t/discourse-theme-cli-errors-with-pnpm-installed-node-modules-due-to-symlinks/341168
**Category:** Development
**Created:** [December 8, 2024, 4:14am UTC](https://meta.discourse.org/t/discourse-theme-cli-errors-with-pnpm-installed-node-modules-due-to-symlinks/341168 "2024-12-08T04:14:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Alteras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alteras/32/179824_2.png) [@Alteras](https://meta.discourse.org/u/Alteras)
#### Post date: [December 8, 2024, 4:14am UTC](https://meta.discourse.org/t/discourse-theme-cli-errors-with-pnpm-installed-node-modules-due-to-symlinks/341168/1 "2024-12-08T04:14:15Z")

</div>

When running the Discourse Theme CLI in a theme component repo with pnpm node\_modules installed, the `discourse_theme watch .` command will return errors about `node_modules/.pnpm` directories already being watched. At a cursory glance, this due to the packages being symlinked.

I have tested this in a fresh GitHub Codespace using the official mermaid TC, using discourse\_theme v2.1.3.

> **Excerpt of error logs**
>
> ```plaintext
> **ERROR: directory is already being watched!**
> 
> Directory: /workspaces/discourse-mermaid-theme-component/node_modules/.pnpm/ember-template-recast@6.1.5/node_modules/@glimmer/reference
> 
> is already being watched through: /workspaces/discourse-mermaid-theme-component/node_modules/.pnpm/@glimmer+reference@0.84.3/node_modules/@glimmer/reference
> 
> MORE INFO: https://github.com/guard/listen/blob/master/README.md
> **ERROR: directory is already being watched!**
> 
> Directory: /workspaces/discourse-mermaid-theme-component/node_modules/.pnpm/@humanwhocodes+retry@0.3.1/node_modules/@humanwhocodes/retry
> 
> is already being watched through: /workspaces/discourse-mermaid-theme-component/node_modules/.pnpm/@humanwhocodes+retry@0.3.1/node_modules/@humanwhocodes/retry
> 
> MORE INFO: https://github.com/guard/listen/blob/master/README.md
> 
> ```

I suspect it has to do with discourse\_theme watching the whole directory without any ignores for `node_modules/.pnpm` or `node_modules` in general.

It’s not a major issue since `discourse_theme watch` seems to work just fine after the errors, but I’m not seeing the `"Watching for changes..."` message after the errors that’s supposed to come from [https://github.com/discourse/discourse\_theme/blob/main/lib/discourse\_theme/watcher.rb#L45-L48](https://github.com/discourse/discourse_theme/blob/main/lib/discourse_theme/watcher.rb#L45-L48), so it could cause some confusion. Plus, it doesn’t feel great moving from npm/yarn to pnpm to only see the CLI throw a bunch of errors onto the screen.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [December 9, 2024, 9:40am UTC](https://meta.discourse.org/t/discourse-theme-cli-errors-with-pnpm-installed-node-modules-due-to-symlinks/341168/2 "2024-12-09T09:40:50Z")

</div>

> [@Alteras](#):
>
> installed, the `discourse_theme watch .`

normally I fire this off from the discourse directory but watch the theme code folder, so something like:

`discourse_theme watch ~code/my-new-theme`

any reason why you are firing it off from the same folder?

I wonder if that’s causing your issues? 🤔

---

<div class="post-metadata">

### Author: ![Alteras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alteras/32/179824_2.png) [@Alteras](https://meta.discourse.org/u/Alteras)
#### Post date: [December 9, 2024, 6:52pm UTC](https://meta.discourse.org/t/discourse-theme-cli-errors-with-pnpm-installed-node-modules-due-to-symlinks/341168/3 "2024-12-09T18:52:59Z")

</div>

I use it from within the TC directory itself since I’m usually developing/testing the theme either against my local dev instance, a dev copy of the forum not on my machine, or the Theme Creator site (which the API key generator doesn’t seem to be working lately). Trying to avoid getting confused about which environment I’m working in.

I’ve git cloned the mermaid TC into the same codespace as a fresh discourse codespace install and tried to run the discourse\_theme watch from the discourse directory instead. Gives the same errors.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [December 9, 2024, 10:15pm UTC](https://meta.discourse.org/t/discourse-theme-cli-errors-with-pnpm-installed-node-modules-due-to-symlinks/341168/4 "2024-12-09T22:15:05Z")

</div>

> [@Alteras](#):
>
> I use it from within the TC directory itself since I’m usually developing/testing the theme either against my local dev instance,

that’s fine, but nothing stopping you running it from another terminal tab … and from the discourse directory?

---

<div class="post-metadata">

### Author: ![Alteras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alteras/32/179824_2.png) [@Alteras](https://meta.discourse.org/u/Alteras)
#### Post date: [December 9, 2024, 11:04pm UTC](https://meta.discourse.org/t/discourse-theme-cli-errors-with-pnpm-installed-node-modules-due-to-symlinks/341168/5 "2024-12-09T23:04:19Z")

</div>

> [@merefield](#):
>
> that’s fine, but nothing stopping you running it from another terminal tab … and from the discourse directory?

Certainly its arbitrary, but its a bit ridiculous to need to run the discourse\_theme from a local clone of discourse when the discourse instance being tested is not the local instance.

Anyway, I have done as you suggested, both in a fresh github codespace, and in my own dev environment, and it still throws the same errors.

* * *

Reading through all of the log (or all the ones that will fit in the terminal history), all the directories it is erroring on is `/node_modules/.pnpm`. Testing and running `discourse_theme` against a different TC that has yet to be updated to use pnpm instead of yarn, I don’t see any errors, so I’m almost 100% certain the issue is with it watching `.pnpm`.

From [Symlinked `node_modules` structure | pnpm](https://pnpm.io/symlinked-node-modules-structure), it looks like the normal structure of node\_modules is preserved by moving all the actual code into `/node_modules/.pnpm` and the rest of directories in `/node_modules/` are just symlinks to `.pnpm`. So ignoring `.pnpm` avoids the “directory is already being watched!” error.

I’ve played a bit with the discourse\_theme gem and added `listener.ignore /node_modules\/\.pnpm/` to the `watcher.rb`, and it seems to work fine without any error messages. It even detected a new pnpm package install.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [January 9, 2025, 6:38pm UTC](https://meta.discourse.org/t/discourse-theme-cli-errors-with-pnpm-installed-node-modules-due-to-symlinks/341168/6 "2025-01-09T18:38:44Z")

</div>

This PR will apply the ignore rule, and silence the warnings. Thanks for creating the topic and investigation @Alteras - these warnings have been annoying me too! 😅

[https://github.com/discourse/discourse\_theme/pull/49](https://github.com/discourse/discourse_theme/pull/49)

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [February 8, 2025, 6:38pm UTC](https://meta.discourse.org/t/discourse-theme-cli-errors-with-pnpm-installed-node-modules-due-to-symlinks/341168/7 "2025-02-08T18:38:57Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
