简体   繁体   中英

npm install not working in windows

I have no idea what is happening here. Hoping someone can help me.

This works great in my mac. But same process in Windows and npm install crashes. This is what I get.

EDIT

I've tried everything I've seen in SO so far and every link Google search produced. I tried the following as suggested here :

rm -rf node_modules
npm install

Didn't work

Ran it as admin,

tried npm install -g

re-started xampp server

turned off Windows defender

checked the PATH for C:\\Program Files\\nodejs

Short of throwing this POS Windows threw a window, pun intended, I've done everything. Hail Apple!

warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
warn fuse@1.4.4 No description
verbose If you need help, you may report this error at:
verbose     <https://github.com/npm/npm/issues>
warn fuse@1.4.4 No repository field.
verbose If you need help, you may report this error at:
verbose     <https://github.com/npm/npm/issues>
warn fuse@1.4.4 No license field.
verbose If you need help, you may report this error at:
verbose     <https://github.com/npm/npm/issues>
verbose stack Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\ScalaCM\node_modules\.staging\accessibility-developer-tools-2e33f290' -> 'C:\xampp\htdocs\ScalaCM\node_modules\accessibility-developer-tools'
verbose stack     at destStatted (C:\Users\Luis\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:25:7)
verbose stack     at C:\Users\Luis\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:276:29
verbose stack     at FSReqWrap.oncomplete (fs.js:123:15)
verbose stack
verbose stack Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\ScalaCM\node_modules\.staging\accessibility-developer-tools-2e33f290' -> 'C:\xampp\htdocs\ScalaCM\node_modules\accessibility-developer-tools'
verbose stack     at Error (native)
verbose cwd C:\xampp\htdocs\ScalaCM
error Windows_NT 10.0.14393
error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Luis\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
error node v6.9.1
error npm  v4.0.2
error path C:\xampp\htdocs\ScalaCM\node_modules\.staging\accessibility-developer-tools-2e33f290
error code EPERM
error errno -4048
error syscall rename
error Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\ScalaCM\node_modules\.staging\accessibility-developer-tools-2e33f290' -> 'C:\xampp\htdocs\ScalaCM\node_modules\accessibility-developer-tools'
error     at destStatted (C:\Users\Luis\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:25:7)
error     at C:\Users\Luis\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:276:29
error     at FSReqWrap.oncomplete (fs.js:123:15)
error
error Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\ScalaCM\node_modules\.staging\accessibility-developer-tools-2e33f290' -> 'C:\xampp\htdocs\ScalaCM\node_modules\accessibility-developer-tools'
error     at Error (native)
error  { Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\ScalaCM\node_modules\.staging\accessibility-developer-tools-2e33f290' -> 'C:\xampp\htdocs\ScalaCM\node_modules\accessibility-developer-tools'
error     at destStatted (C:\Users\Luis\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:25:7)
error     at C:\Users\Luis\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:276:29
error     at FSReqWrap.oncomplete (fs.js:123:15)
error
error Error: EPERM: operation not permitted, rename 'C:\xampp\htdocs\ScalaCM\node_modules\.staging\accessibility-developer-tools-2e33f290' -> 'C:\xampp\htdocs\ScalaCM\node_modules\accessibility-developer-tools'
error     at Error (native) parent: 'fuse' }
error Please try running this command again as root/Administrator.
verbose exit [ -4048, true ]

node -v gives me a version v6.9.1

npm -v gives me a version as well 4.0.2

Which proves they are all installed fine, am I right?

After countless hours of debugging and researching, I decided to install in a different machine to see if the problem was with my Node installation. It worked.

So for everyone who may come across this, know that the possibility to uninstall node and delete NPM will be there. This is what I did. I believe it is the safest way to solve the problem and all the rest of your applications installed in your machine will still work. I credit this answer for these steps, although I had other npm and node_modules in other locations. So do a quick search for these and unless they are part of an application, make sure they are deleted as well.

  1. Uninstall from Programs & Features with the uninstaller.

  2. Reboot (or you probably can get away with killing all node-related processes from Task Manager).

  3. Look for these folders and remove them (and their contents) if any still exist. Depending on the version you installed, UAC settings, and CPU architecture, these may or may not exist:

    • C:\\Program Files (x86)\\Nodejs
    • C:\\Program Files\\Nodejs
    • C:\\Users\\{User}\\AppData\\Roaming\\npm (or %appdata%\\npm )
    • C:\\Users\\{User}\\AppData\\Roaming\\npm-cache (or %appdata%\\npm-cache )
    • C:\\Users\\{User}\\.npmrc (and possibly check for that without the . prefix too)
  4. Check your %PATH% environment variable to ensure no references to Nodejs or npm exist.

  5. If it's still not uninstalled, type where node at the command prompt and you'll see where it resides -- delete that (and probably the parent directory) too.

  6. Reboot, for good measure.

Please read the error carefully. It's saying :

fsevents@1.0.17: wanted {"os":"darwin","arch":"any"}

The FSEvents API in OS X allows applications to register for notifications of changes to a given directory tree.

It needs OS X, Because some of npm dependencies are using fsevents that's by It's breaking in windows.

https://github.com/strongloop/fsevents

Update:

As you told It's working without fsevents then you can follow these steps:

install npm-check-updates and try again.

 npm install -g npm-check-updates
 ncu -u       #It will update the npm dependencies.
 rm -fr node_modules
 npm install

It will update the dependencies and install the dependencies.
Hope It will work :)

please try to open the console as a administrator. do right Click on the commandLine and select "open as administrator" then try installing dependency.

update and then install again

npm install -g npm-check-updates

npm install

add this to fix any errors

npm audit fix

唯一对我有用的解决方案是从 C:\\Users(your username)\\AppData\\Roaming 中删除 npm 和 npm-cache 卸载 nodejs 并重新安装它

I tried to disabled all my antivirus and firewall, clear npm cache, and do cache verify but nothing works. The only thing that works on my end is to install the Node Version Manager nvm .

How Node Version Manager works?

Permission errors can occur when packages are installed globally. If this is the case, npm may need to be set up to operate without elevated permissions. This where nvm comes in. It lets you install a different node version without triggering the administrative access.

  1. If you have existing Node installed, I recommend uninstalling it like the process given by LOTUSMS above

Uninstall from Programs & Features with the uninstaller.

Reboot (or you probably can get away with killing all node-related processes from Task Manager).

Look for these folders and remove them (and their contents) if any still exist. Depending on the version you installed, UAC settings, and CPU architecture, these may or may not exist:

C:\\Program Files (x86)\\Nodejs C:\\Program Files\\Nodejs

C:\\Users{User}\\AppData\\Roaming\\npm (or %appdata%\\npm)

C:\\Users{User}\\AppData\\Roaming\\npm-cache (or %appdata%\\npm-cache)

C:\\Users{User}.npmrc (and possibly check for that without the . prefix too) Check your %PATH% environment variable to ensure no references to Nodejs or npm exist.

If it's still not uninstalled, type where node at the command prompt and you'll see where it resides -- delete that (and probably the parent directory) too.

  1. Install nvm here - https://github.com/coreybutler/nvm-windows . or you can use curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

  2. Run nvm or command -v nvm . If something prints, the installation was successful.

  3. Install prefered node version - eg nvm use 16.3.0

  4. Check if the node and npm are properly install. Just run node -v and npm -v

  5. Enjoy npm installation :D

If npm install is not not working, then you can use this command-

 npm install --legacy-peer-deps

This works for me.

如果您使用 nvm 安装了 node 和 npm,那么您可以使用nvm uninstall 5.5.5卸载它,然后使用nvm install 5.5.5重新安装,这解决了我的问题,我不必进入并删除模块或更改路径

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM