nrwl / nx

Smart Monorepos ยท Fast CI
https://nx.dev
MIT License
23.69k stars 2.36k forks source link

Cannot install nx globally/locally #26144

Closed JohnMichaelangelo20 closed 4 months ago

JohnMichaelangelo20 commented 5 months ago

Current Behavior

nx

I'm using windows 10

I tried installing other packages/library globally it works (I know that this isn't about permission)... nx is the only thing that is not installing

using nvm to download node

node version: 20.13.1 npm version: 10.5.2

nx 2

i even tried to rebuild the npm to be sure but yet it's still have a problem

Expected Behavior

I wanted this one to be installed

GitHub Repo

No response

Steps to Reproduce

  1. Open a terminal (doesn't matter if run as admin or not)
  2. npm install nx -g

Nx Report

npm WARN cleanup Failed to remove some directories [
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\JohnM\\AppData\\Roaming\\nvm\\v20.13.1\\node_modules\\nx',
npm WARN cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\JohnM\AppData\Roaming\nvm\v20.13.1\node_modules\nx\node_modules\js-yaml'] {
npm WARN cleanup       errno: -4048,
npm WARN cleanup       code: 'EPERM',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\JohnM\\AppData\\Roaming\\nvm\\v20.13.1\\node_modules\\nx\\node_modules\\js-yaml'
npm WARN cleanup     }
npm WARN cleanup   ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path C:\Users\JohnM\AppData\Roaming\nvm\v20.13.1\node_modules\nx
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node ./bin/post-install
npm ERR! C:\Users\JohnM\AppData\Roaming\nvm\v20.13.1\node_modules\nx\src\native\native-bindings.js:244
npm ERR!     throw loadError
npm ERR!     ^
npm ERR!
npm ERR! Error: The specified module could not be found.
npm ERR! \\?\C:\Users\JohnM\AppData\Local\Temp\nx-native-file-cache-41edfcf\19.1.0-nx.win32-x64-msvc.node
npm ERR!     at Module._extensions..node (node:internal/modules/cjs/loader:1454:18)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1208:32)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:1024:12)
npm ERR!     at Module._load (C:\Users\JohnM\AppData\Roaming\nvm\v20.13.1\node_modules\nx\src\native\index.js:60:27)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1233:19)
npm ERR!     at require (node:internal/modules/helpers:179:18)
npm ERR!     at Object.<anonymous> (C:\Users\JohnM\AppData\Roaming\nvm\v20.13.1\node_modules\nx\src\native\native-bindings.js:66:29)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1358:14)
npm ERR!     at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1208:32) {
npm ERR!   code: 'ERR_DLOPEN_FAILED'
npm ERR! }
npm ERR!
npm ERR! Node.js v20.13.1

npm ERR! A complete log of this run can be found in: C:\Users\JohnM\AppData\Local\npm-cache\_logs\2024-05-28T04_16_26_092Z-debug-0.log

Failure Logs

No response

Package Manager Version

10.5.2

Operating System

Additional Information

No response

Wurielle commented 5 months ago

Having this issue on Windows 10 as well.

The file does exist in C:\Users\user\AppData\Local\Temp\nx-native-file-cache-41edfcf\19.1.0-nx.win32-x64-msvc.node but it seems like nx adds \\?\ in front of the path it's trying to load just like in the error above: npm ERR! \\?\C:\Users\user\AppData\Local\Temp\nx-native-file-cache-41edfcf\19.1.0-nx.win32-x64-msvc.node

Setting NX_NATIVE_FILE_CACHE_DIRECTORY = "/tmp/mycache" in my env variable will result in the same issue: npm ERR! \\?\C:\tmp\mycache\AppData\Local\Temp\nx-native-file-cache-41edfcf\19.1.0-nx.win32-x64-msvc.node

I tried to downgrade the version of nx to 18.3.4 as well but the same issue occurs so I'm assuming it's not new.

MaxKless commented 5 months ago

Hey! For now it should be possible to set the NX_NATIVE_FILE_CACHE_DIRECTORY variable to something else. Can you check whether it works for you if you specify an absolute path there? I don't think the \\? is the issue, it looks like that's just how windows specifies potentially very long paths.

The module loading error is a bit of a misdirect I think as it shadows the true, underlying error. In this case this is ERR_DLOPEN_FAILED which I've never heard of before. @Wurielle do you get the same stack trace with ERR_DLOPEN_FAILED? Does the error code change if you specify NX_NATIVE_FILE_CACHE_DIRECTORY? Since it's in 18.3.4, it sounds like it might be a different issue.

@JohnMichaelangelo20 can you make sure that when you try to npm i nx -g, there are no other processes that might somehow use nx (vscode, intellij, daemon,...) running at the same time? It would give me more information. Thank you :)

JohnMichaelangelo20 commented 5 months ago

Hey! For now it should be possible to set the NX_NATIVE_FILE_CACHE_DIRECTORY variable to something else. Can you check whether it works for you if you specify an absolute path there? I don't think the \\? is the issue, it looks like that's just how windows specifies potentially very long paths.

The module loading error is a bit of a misdirect I think as it shadows the true, underlying error. In this case this is ERR_DLOPEN_FAILED which I've never heard of before. @Wurielle do you get the same stack trace with ERR_DLOPEN_FAILED? Does the error code change if you specify NX_NATIVE_FILE_CACHE_DIRECTORY? Since it's in 18.3.4, it sounds like it might be a different issue.

@JohnMichaelangelo20 can you make sure that when you try to npm i nx -g, there are no other processes that might somehow use nx (vscode, intellij, daemon,...) running at the same time? It would give me more information. Thank you :)

I did run the command without anything being opened. I also just reformat my whole device and the very first I did was to install node and install nx and the error occurs from the beggining even if it's a fresh device.

MaxKless commented 5 months ago

is there anything else that might be special about your machine? multiple users, permissions? Have you tried setting the 'NX_NATIVE_FILE_CACHE_DIRECTORY' environment variable to another place that you surely have access to? I've tried reproducing and on my windows machine it installs just fine... So I need some more information. Can you trace it to an exact version where it worked before? Maybe you can record a video of it happening?

JohnMichaelangelo20 commented 5 months ago

Hi @MaxKless ๐Ÿ‘‹๐Ÿผ No, there is nothing special on my machine.

But npm i nx -g was working when it was on windows 11 and had to downgrade it to windows 10 but since then I got this error (here is what I download https://www.microsoft.com/en-us/software-download/windows10)

This is what I followed https://www.youtube.com/watch?v=hnBO1aTgrVs

and I tried to install & uninstall node js got this pop up with different .msi each time I'm installing node that needed to be yes

Do you want to allow this app to make changes to your device?

8e80.msi` / 968e.msi / 9e9c.msi / 27e0f.msi

Multiple Users image

User Permission image

What is installed in my device (nvm is only here because I tried to install nx and have removed node js but same error; I tried install nx via node downloaded from nvm and node is uninstall and vice versa, same error ๐Ÿ˜Ÿ ) image

Windows C: Security settings image

Do I need something to be enabled/checked here? image

MaxKless commented 5 months ago

@JohnMichaelangelo20 @Wurielle can you try setting the NX_NATIVE_FILE_CACHE_DIRECTORY env variable to another place that you have access to and check that it works with that workaround?

JohnMichaelangelo20 commented 5 months ago

@MaxKless I added it to a new folder

image

I checked if I have access to that file (I have) and installed the nx again and got this (kindly see screenshot)

image

but it is here

image

MaxKless commented 5 months ago

huh, interesting... does the same happen if you have a folder name without any spaces?

JohnMichaelangelo20 commented 5 months ago

yes, the first one I tried was without the space. Same error given.

MaxKless commented 5 months ago

sorry I'm poking a little bit in the dark here since I can't reproduce it myself. Have you tried on node 18 instead of 20?

JohnMichaelangelo20 commented 5 months ago

yes, same error. ๐Ÿ˜ž

fthiery commented 5 months ago

For the record, i had the crash on Linux, probably because i was running docker with --tmpfs /tmp ; defining NX_NATIVE_FILE_CACHE_DIRECTORY to another location fixed it.

Avivbens commented 5 months ago

Removing the native cache file resolved the issue for me ๐Ÿ˜„

Your file directory might be something else - note that

rm -rf /private/var/folders/rw/z_n8j7kd5_18t2bdrx7s65vw0000gq/T/nx-native-file-cache-84f6168
unkbjct commented 5 months ago

Need to install Microsoft Visual C++ 2015 Redistributable package

see more here https://github.com/lerna/lerna/issues/3612#issuecomment-1499259377

JohnMichaelangelo20 commented 4 months ago

Hello everyone, I didn't keep track of which recent updates in nx did solve this issue but I tried it now and it is now working. ๐Ÿ˜„

Bruno-Devs commented 4 months ago

Hello @JohnMichaelangelo20 i am have same issue as you, i also tried to follow the two possible solution you used to get yours to work. i would like to know which of them seems like the right one to do. nx-issue

JohnMichaelangelo20 commented 4 months ago

@Bruno-Devs Hi, may I see your control panel?

Have you checked this one out? https://github.com/lerna/lerna/issues/3612#issuecomment-1499259377

https://www.microsoft.com/en-us/download/details.aspx?id=48145

Bruno-Devs commented 4 months ago

@Bruno-Devs Hi, may I see your control panel?

Have you checked this one out? lerna/lerna#3612 (comment)

https://www.microsoft.com/en-us/download/details.aspx?id=48145

i have tried the two of them control panel

JohnMichaelangelo20 commented 4 months ago

Control Panel\Programs\Programs and Features

sorry, this path rather @Bruno-Devs .

Bruno-Devs commented 4 months ago

this is it Screenshot (77) Screenshot (78)

JohnMichaelangelo20 commented 4 months ago

image

@Bruno-Devs I only have this two.

Bruno-Devs commented 4 months ago

did you restart your system after you uninstalled it

JohnMichaelangelo20 commented 4 months ago

@Bruno-Devs yes, better clean everything and restart before installing it.

github-actions[bot] commented 3 months ago

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.