Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porter watch won't work #23

Open
calebdw opened this issue Jan 27, 2023 · 7 comments
Open

Porter watch won't work #23

calebdw opened this issue Jan 27, 2023 · 7 comments
Labels
question Further information is requested

Comments

@calebdw
Copy link

calebdw commented Jan 27, 2023

Hello,

I installed chokidar globally per the docs, however, executing the porter watch command yields the following error:

Watcher process has terminated. Please ensure Node and chokidar are installed.

Executing npm list -g shows I have chokidar installed:

$ npm list -g
/usr/lib
├── @johnnymorganz/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
@dpslwk
Copy link
Contributor

dpslwk commented Feb 1, 2023

Im also seeing this, I believe that the watch node script can not import the global installed chokidar

Watcher process has terminated. Please ensure Node and chokidar are installed.
node:internal/modules/cjs/loader:1042
  throw err;
  ^

Error: Cannot find module 'chokidar'
Require stack:
- /Users/matt/.porter/file-watcher.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/Users/matt/.porter/file-watcher.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/matt/.porter/file-watcher.js' ]
}

Node.js v18.13.0

I'm on macOS
if I go to ~/.porter in the directory with file-watcher.js
and run npm install chokidar there things work as expected

@PhiloNL
Copy link
Contributor

PhiloNL commented Feb 2, 2023

It seems your node path is not registered:
https://nodejs.org/api/modules.html#loading-from-the-global-folders

@PhiloNL PhiloNL closed this as completed Feb 2, 2023
@dpslwk
Copy link
Contributor

dpslwk commented Feb 2, 2023

defining node path in my normal .zsenv did not help me since what ever environment porter is starting the watcher from does not pick that up

perhaps adding NODE_PATH=$(npm root --quiet -g) as an environment in porters [program:watcher] might work for everyone

@calebdw
Copy link
Author

calebdw commented Feb 2, 2023

Also, NPM already searches the following GLOBAL paths:

Additionally, Node.js will search in the following list of GLOBAL_FOLDERS:

1: $HOME/.node_modules
2: $HOME/.node_libraries
3: $PREFIX/lib/node

However, explicitly setting the NODE_PATH variable has no effect on the error message.

@PhiloNL
Copy link
Contributor

PhiloNL commented Feb 3, 2023

Are you sure this is also where chokidar got installed?
I'm using nvm for example, and this path is not automatically loaded, for example, I have to export the following path for Porter to work:

export NODE_PATH=/Users/developer/.nvm/versions/node/v18.10.0/lib/node_modules

@PhiloNL PhiloNL reopened this Feb 3, 2023
@PhiloNL PhiloNL added the question Further information is requested label Feb 3, 2023
@calebdw
Copy link
Author

calebdw commented Feb 3, 2023

It looks like it's installed there:

$ ll /usr/lib/node_modules/
total 44K
drwxr-xr-x  11 root root 4.0K Jan 27 11:46  ./
drwxr-xr-x 129 root root 4.0K Jan 24 09:07  ../
drwxr-xr-x   7 root root 4.0K Aug  2  2022  blade-formatter/
drwxr-xr-x   5 root root 4.0K Jan 27 11:46  chokidar/
drwxr-xr-x   4 root root 4.0K Jan 16 09:17  corepack/
drwxr-xr-x   7 root root 4.0K Jul 27  2022  eslint/
drwxr-xr-x   3 root root 4.0K Aug  2  2022 '@johnnymorganz'/
drwxr-xr-x   6 root root 4.0K Jul 25  2022  neovim/
drwxr-xr-x   3 root root 4.0K Aug  2  2022  nginxbeautifier/
drwxr-xr-x   7 root root 4.0K Jan 16 09:17  npm/
drwxr-xr-x   2 root root 4.0K Sep 10 08:32  tree-sitter-cli/

@radermacher
Copy link

radermacher commented Mar 29, 2023

I have the same issue as described above.

echo $NODE_PATH in the terminal shows the correct path.
Executing npm list -g shows I have chokidar installed

Error message in watcher.log:
Watcher process has terminated. Please ensure Node and chokidar are installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants