node.js npm 安装在 Windows 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41570364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install not working in windows
提问by LOTUSMS
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.
这在我的 Mac 上非常有效。但是 Windows 和 npm install 中的相同过程崩溃了。这就是我得到的。
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:
到目前为止,我已经尝试了我在 SO 中看到的所有内容以及 Google 搜索生成的每个链接。我按照此处的建议尝试了以下操作:
rm -rf node_modules
npm install
Didn't work
没用
Ran it as admin,
以管理员身份运行它,
tried npm install -g
试过 npm install -g
re-started xampp server
重新启动 xampp 服务器
turned off Windows defender
关闭 Windows Defender
checked the PATH for C:\Program Files\nodejs
检查 C:\Program Files\nodejs 的 PATH
Short of throwing this POS Windows threw a window, pun intended, I've done everything. Hail Apple!
没有扔这个 POS Windows 扔了一个窗口,双关语意为,我已经做了一切。苹果万岁!
warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: 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 [email protected] No description
verbose If you need help, you may report this error at:
verbose <https://github.com/npm/npm/issues>
warn [email protected] No repository field.
verbose If you need help, you may report this error at:
verbose <https://github.com/npm/npm/issues>
warn [email protected] 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
node -v 给我一个版本 v6.9.1
npm -v gives me a version as well 4.0.2
npm -v 也给了我一个版本 4.0.2
Which proves they are all installed fine, am I right?
这证明它们都安装得很好,对吗?
采纳答案by LOTUSMS
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.
经过无数个小时的调试和研究,我决定安装在另一台机器上,看看问题是否出在我的 Node 安装上。有效。
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 answerfor 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.
因此,对于可能遇到此问题的每个人,都知道卸载节点和删除 NPM 的可能性将存在。这就是我所做的。我相信这是解决问题的最安全方法,并且您机器中安装的所有其他应用程序仍然可以工作。我将这些步骤归功于这个答案,尽管我在其他位置有其他 npm 和 node_modules。因此,请快速搜索这些内容,除非它们是应用程序的一部分,否则请确保它们也被删除。
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)\NodejsC:\Program Files\NodejsC:\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 variableto ensure no references toNodejsornpmexist.If it's stillnot uninstalled, type
where nodeat the command prompt and you'll see where it resides -- delete that (and probably the parent directory) too.Reboot, for good measure.
使用卸载程序从程序和功能中卸载。
重新启动(或者您可能可以从任务管理器中杀死所有与节点相关的进程)。
查找这些文件夹并删除它们(及其内容)(如果仍然存在)。根据您安装的版本、UAC 设置和 CPU 架构,这些可能存在也可能不存在:
C:\Program Files (x86)\NodejsC:\Program Files\NodejsC:\Users\{User}\AppData\Roaming\npm(或%appdata%\npm)C:\Users\{User}\AppData\Roaming\npm-cache(或%appdata%\npm-cache)C:\Users\{User}\.npmrc(也可能在没有.前缀的情况下检查)
检查您的
%PATH%环境变量以确保没有引用Nodejs或npm存在。如果它仍未卸载,请
where node在命令提示符下键入,您将看到它所在的位置——也删除它(可能还有父目录)。重新启动,很好的措施。
回答by Vishnu Mishra
Please read the error carefully. It's saying :
请仔细阅读错误。它说:
[email protected]: wanted {"os":"darwin","arch":"any"}
The FSEvents API in OS X allows applications to register for notifications of changes to a given directory tree.
OS X 中的 FSEvents API 允许应用程序注册给定目录树的更改通知。
It needs OS X, Because some of npm dependencies are using fsevents that's by It's breaking in windows.
它需要 OS X,因为一些 npm 依赖项正在使用 fsevents,它在 Windows 中被破坏了。
https://github.com/strongloop/fsevents
https://github.com/strongloop/fsevents
Update:
更新:
As you told It's working without fsevents then you can follow these steps:
正如您所说,它可以在没有 fsevents 的情况下工作,那么您可以按照以下步骤操作:
install npm-check-updatesand 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 :)
它将更新依赖项并安装依赖项。
希望它会起作用:)
回答by yatheesha
update and then install again
更新然后重新安装
npm install -g npm-check-updates
npm install
npm install
add this to fix any errors
添加此项以修复任何错误
npm audit fix
npm 审计修复
回答by Darpan Rangari
please try to open the console as a administrator. do right Click on the commandLine and select "open as administrator" then try installing dependency.
请尝试以管理员身份打开控制台。右键单击命令行并选择“以管理员身份打开”,然后尝试安装依赖项。

