paulmillr / chokidar

Minimal and efficient cross-platform file watching library
https://paulmillr.com
MIT License
10.95k stars 580 forks source link

Packages that uses Chokidar fails to install on npm > 10.3.0 #1319

Closed z-x closed 3 months ago

z-x commented 4 months ago

Describe the bug

It seems that after updating npm to version above 10.3.0, packages that uses Chokidar blocks npm install from remote repository. An example package that uses Chokidar is: https://github.com/Platform-OS/pos-cli

When you clone the repo and install the package locally, everything works. But after publishing to npm it seems that running npm install -g @platformos/pos-cli fails by trying to rebuild something using node-gyp.

I've traced the problem to Chokidar by trial and error. @platformos/pos-cli uses Chokidar directly to observe files, but also we are using LiveReload as dependency (and LiveReload is using Chokidar) and it seems that only removing both of those from the package solves installing on newest npm.

There is a related issue opened in Node repo: https://github.com/nodejs/node/issues/52436

npm error code 1
npm error path C:\Users\zx\AppData\Roaming\npm\node_modules\@platformos\pos-cli\node_modules\fsevents
npm error command failed
npm error command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@8.4.1
npm error gyp info using node@20.12.2 | win32 | x64
npm error gyp ERR! find Python
npm error gyp ERR! find Python Python is not set from command line or npm configuration
npm error gyp ERR! find Python Python is not set from environment variable PYTHON
npm error gyp ERR! find Python checking if "python3" can be used
npm error gyp ERR! find Python - "python3" is not in PATH or produced an error
npm error gyp ERR! find Python checking if "python" can be used
npm error gyp ERR! find Python - "python" is not in PATH or produced an error
npm error gyp ERR! find Python checking if Python is C:\Users\zx\AppData\Local\Programs\Python\Python39\python.exe
npm error gyp ERR! find Python - "C:\Users\zx\AppData\Local\Programs\Python\Python39\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files\Python39\python.exe
npm error gyp ERR! find Python - "C:\Program Files\Python39\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Users\zx\AppData\Local\Programs\Python\Python39-32\python.exe
npm error gyp ERR! find Python - "C:\Users\zx\AppData\Local\Programs\Python\Python39-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files\Python39-32\python.exe
npm error gyp ERR! find Python - "C:\Program Files\Python39-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python39-32\python.exe
npm error gyp ERR! find Python - "C:\Program Files (x86)\Python39-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Users\zx\AppData\Local\Programs\Python\Python38\python.exe
npm error gyp ERR! find Python - "C:\Users\zx\AppData\Local\Programs\Python\Python38\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files\Python38\python.exe
npm error gyp ERR! find Python - "C:\Program Files\Python38\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Users\zx\AppData\Local\Programs\Python\Python38-32\python.exe
npm error gyp ERR! find Python - "C:\Users\zx\AppData\Local\Programs\Python\Python38-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files\Python38-32\python.exe
npm error gyp ERR! find Python - "C:\Program Files\Python38-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python38-32\python.exe
npm error gyp ERR! find Python - "C:\Program Files (x86)\Python38-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Users\zx\AppData\Local\Programs\Python\Python37\python.exe
npm error gyp ERR! find Python - "C:\Users\zx\AppData\Local\Programs\Python\Python37\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files\Python37\python.exe
npm error gyp ERR! find Python - "C:\Program Files\Python37\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Users\zx\AppData\Local\Programs\Python\Python37-32\python.exe
npm error gyp ERR! find Python - "C:\Users\zx\AppData\Local\Programs\Python\Python37-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files\Python37-32\python.exe
npm error gyp ERR! find Python - "C:\Program Files\Python37-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python37-32\python.exe
npm error gyp ERR! find Python - "C:\Program Files (x86)\Python37-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Users\zx\AppData\Local\Programs\Python\Python36\python.exe
npm error gyp ERR! find Python - "C:\Users\zx\AppData\Local\Programs\Python\Python36\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files\Python36\python.exe
npm error gyp ERR! find Python - "C:\Program Files\Python36\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Users\zx\AppData\Local\Programs\Python\Python36-32\python.exe
npm error gyp ERR! find Python - "C:\Users\zx\AppData\Local\Programs\Python\Python36-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files\Python36-32\python.exe
npm error gyp ERR! find Python - "C:\Program Files\Python36-32\python.exe" could not be run
npm error gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python36-32\python.exe
npm error gyp ERR! find Python - "C:\Program Files (x86)\Python36-32\python.exe" could not be run
npm error gyp ERR! find Python checking if the py launcher can be used to find Python 3
npm error gyp ERR! find Python - "py.exe" is not in PATH or produced an error
npm error gyp ERR! find Python
npm error gyp ERR! find Python **********************************************************
npm error gyp ERR! find Python You need to install the latest version of Python.
npm error gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm error gyp ERR! find Python you can try one of the following options:
npm error gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
npm error gyp ERR! find Python   (accepted by both node-gyp and npm)
npm error gyp ERR! find Python - Set the environment variable PYTHON
npm error gyp ERR! find Python - Set the npm configuration variable python:
npm error gyp ERR! find Python   npm config set python "C:\Path\To\python.exe"
npm error gyp ERR! find Python For more information consult the documentation at:
npm error gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm error gyp ERR! find Python **********************************************************
npm error gyp ERR! find Python
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: Could not find any Python installation to use
npm error gyp ERR! stack     at PythonFinder.fail (C:\Users\zx\AppData\Roaming\npm\node_modules\@platformos\pos-cli\node_modules\node-gyp\lib\find-python.js:330:47)
npm error gyp ERR! stack     at PythonFinder.runChecks (C:\Users\zx\AppData\Roaming\npm\node_modules\@platformos\pos-cli\node_modules\node-gyp\lib\find-python.js:159:21)
npm error gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\zx\AppData\Roaming\npm\node_modules\@platformos\pos-cli\node_modules\node-gyp\lib\find-python.js:228:18)
npm error gyp ERR! stack     at PythonFinder.execFileCallback (C:\Users\zx\AppData\Roaming\npm\node_modules\@platformos\pos-cli\node_modules\node-gyp\lib\find-python.js:294:16)
npm error gyp ERR! stack     at exithandler (node:child_process:430:5)
npm error gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:442:5)
npm error gyp ERR! stack     at ChildProcess.emit (node:events:518:28)
npm error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
npm error gyp ERR! stack     at onErrorNT (node:internal/child_process:484:16)
npm error gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
npm error gyp ERR! System Windows_NT 10.0.22631
npm error gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\zx\\AppData\\Roaming\\npm\\node_modules\\@platformos\\pos-cli\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm error gyp ERR! cwd C:\Users\zx\AppData\Roaming\npm\node_modules\@platformos\pos-cli\node_modules\fsevents
npm error gyp ERR! node -v v20.12.2
npm error gyp ERR! node-gyp -v v8.4.1
npm error gyp ERR! not ok
npm error A complete log of this run can be found in: C:\Users\zx\AppData\Local\npm-cache\_logs\2024-05-27T10_43_48_965Z-debug-0.log

Versions (please complete the following information):

To Reproduce:

It's a little tricky because it fails only when installing a published package from npm. So npm i -g @platformos/pos-cli on latest npm shows the issue. It fails on install when Chokidar is a dependency (even not direct).

Expected behavior It should install as it was working on npm <= 10.3.0. Downgrading npm 'fixes' the issue.

Additional context I am not sure if this is Chokidar problem or something broken with npm or possibly it's fsevents fault: https://github.com/fsevents/fsevents/issues/378

z-x commented 4 months ago

It seems that when I manually install fsevents like so: npm i fsevents@latest -f --save-optional - everything starts to work and I am able to install the package without node-gyp trying to rebuild things.