Closed vpernjek closed 2 months ago
I am seeing a similar error on windows.
npm error path C:\<PROJECT-NAME>\node_modules\nx
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c node ./bin/post-install
npm error C:\<PROJECT-NAME>\node_modules\nx\src\native\native-bindings.js:244
npm error throw loadError
npm error ^
npm error
npm error Error: \\?\C:\Users\<USERNAME>\AppData\Local\Temp\nx-native-file-cache-79bc8ab\19.3.2-nx.win32-x64-msvc.node is not a valid Win32 application.
npm error \\?\C:\Users\<USERNAME>\AppData\Local\Temp\nx-native-file-cache-79bc8ab\19.3.2-nx.win32-x64-msvc.node
npm error at Module._extensions..node (node:internal/modules/cjs/loader:1465:18)
npm error at Module.load (node:internal/modules/cjs/loader:1206:32)
npm error at Module._load (node:internal/modules/cjs/loader:1022:12)
npm error at Module._load (C:\<PROJECT-NAME>\node_modules\nx\src\native\index.js:60:27)
npm error at Module.require (node:internal/modules/cjs/loader:1231:19)
npm error at require (node:internal/modules/helpers:179:18)
npm error at Object.<anonymous> (C:\<PROJECT-NAME>\node_modules\nx\src\native\native-bindings.js:66:29)
npm error at Module._compile (node:internal/modules/cjs/loader:1369:14)
npm error at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
npm error at Module.load (node:internal/modules/cjs/loader:1206:32) {
npm error code: 'ERR_DLOPEN_FAILED'
npm error }
npm error
npm error Node.js v20.12.2
npm error A complete log of this run can be found in: C:\Users\<USERNAME>\AppData\Local\npm-cache\_logs\2024-07-01T15_05_49_081Z-debug-0.log
I recently updated nx from 17 to 19, and updated node from 18 to 20.
I have found a solution to this issue, at least for myself on windows.
I tried a bunch of things, including restarting my computer, deleting the node_modules folder, deleting the .nx folder, downgrading back to node 18, but none of that worked.
What did work was to go into the AppData\Local\Temp\
folder and delete the nx-native-file-cache-79bc8ab
folder. I initially was not able to delete this folder due to it being in use, despite vs code and all command prompts being closed. In task manager, it looks like there was a node process left running from a previous install that was sitting in the background despite the command prompt having been closed. After terminating this node process, I was able to delete the nx file cache folder. After deleting this folder, I was able to successfully run npm install
nx 19.3.2 and node 20.15.0.
I am not seeing nx-native-file-cache-36db5b1 folder anywhere on macOS unfortunately..
@vpernjek - Did you check in the /var folder? I was facing the same issue and I removed the nx-native-file-cache files from the /var folder in macOs (This is linked to /private/var) (also remove if any package-lock, node_modules, .nx folder if exists) :
so in your case, the path should be
cd /var/folders/4t/pyry0n8510n6prglnzqb9knr0000gn/T/
rm -r nx-native-file-cache-79bc8ab
npm i
This hopefully should work.
Thanks everyone for the input :) If anything happens in the future, you can also try redefining the NX_NATIVE_FILE_CACHE_DIRECTORY
env variable to point to a different location without permission problems.
This is also happening to me as well. It is quite annoying.
This is a true bug in nx. It happens constantly in my Github-Actions CI as well.
@vpernjek could you reopen this?
I can get consistent reproductions of this issue.
I've got a reproduction here, just check out this repository:
https://github.com/bhouston/nx-install-failure
And the run these two commands over and over again until you get a failure. On my current machine I get a failure about 50% of the time.
# clear previous install
npm run clean
# do a fresh install
npm install
Remember that I am on a Mac with the latest OS (beta 15, the latest) using node 22.2.0. If you have a different OS or node version, your results may differ.
I find this error is also occurring in Linux VMs that Github Actions uses. Thus I believe it is not related to MacOS beta.
As you were reopening the bug @MaxKless, I refiled this as a new bug here: https://github.com/nrwl/nx/issues/26987
I have identified a fix, I upgraded lerna from "8.1.2" to "8.1.6". I do not think that should have made a difference but it did.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
Trying to npm install dependencies throws error. I tried to clean install nx globally and delete node_modules and package-lock.json locally and adding the --include=optional flag as per troubleshoot guide but it didn't change.
The behaviour started after upgrading from nx 18 to 19. Reinstalled nvm and node version 21.7.3. Clean install nx globally to latest version 19.3.2.
Expected Behavior
To be able to npm install project dependencies
GitHub Repo
No response
Steps to Reproduce
Nx Report
Failure Logs
Package Manager Version
npm v10.5.0
Operating System
Additional Information
MacOS Sonoma 14.1.2 Apple M2 Pro