node.js - npm install 在 Windows 上随机失败

标签 node.js windows npm

在我们的 Windows 构建服务器上运行 npm install 时,该命令间歇性地失败并显示

error   errno: -4048,
error   code: 'EPERM',
error   path: 'C:\\Users\\bamboo\\AppData\\Roaming\\npm-cache\\readable-stream\\1.0.33\\package\\package.json',
error   parent: 'through2' }
error Please try running this command again as root/Administrator.

即使命令是在以管理员身份运行的命令提示符中以管理员身份执行的。命令失败的包每次都不同,其他 Windows 计算机在使用相同源运行 npm install 时没有此问题。

我尝试过 npm cache clean 并手动删除 C:\Users\%username%\AppData\npm-cache 目录的内容,但没有成功。我还检查了 npm-cache 目录、NodeJS 安装目录和包含源代码检查的目录的权限,所有这些都表明管理员组具有完全权限,并且管理员用户(正在运行 npm install 命令)拥有该目录。我还尝试了最新版本的 npm (2.13.4) 以及旧版本 (2.11.3)。

是什么导致了这个权限错误?

以下是 npm-debug.log 文件的内容:

236980 info install write-file-atomic@1.1.2
236981 info postinstall write-file-atomic@1.1.2
236982 info install npm@2.13.4
236983 info postinstall npm@2.13.4
236984 verbose unlock done using C:\Users\bamboo\AppData\Roaming\npm-cache\_locks\npm-723363012edbbbaa.lock for c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\npm
236985 verbose stack Error: EPERM, rename 'C:\Users\bamboo\AppData\Roaming\npm-cache\readable-stream\1.0.33\package\package.json'
236985 verbose stack     at Error (native)
236986 verbose cwd c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web
236987 error Windows_NT 6.3.9600
236988 error argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--msvs_version=2013"
236989 error node v0.12.7
236990 error npm  v2.11.3
236991 error path C:\Users\bamboo\AppData\Roaming\npm-cache\readable-stream\1.0.33\package\package.json
236992 error code EPERM
236993 error errno -4048
236994 error Error: EPERM, rename 'C:\Users\bamboo\AppData\Roaming\npm-cache\readable-stream\1.0.33\package\package.json'
236994 error     at Error (native)
236994 error  { [Error: EPERM, rename 'C:\Users\bamboo\AppData\Roaming\npm-cache\readable-stream\1.0.33\package\package.json']
236994 error   errno: -4048,
236994 error   code: 'EPERM',
236994 error   path: 'C:\\Users\\bamboo\\AppData\\Roaming\\npm-cache\\readable-stream\\1.0.33\\package\\package.json',
236994 error   parent: 'through2' }
236995 error Please try running this command again as root/Administrator.
236996 verbose exit [ -4048, true ]
236997 verbose unbuild node_modules\gulp-replace-task\node_modules\through2
236998 info preuninstall through2@0.6.5
236999 info uninstall through2@0.6.5
237000 verbose unbuild rmStuff through2@0.6.5 from c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules
237001 verbose unbuild rmStuff in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task\node_modules
237002 info postuninstall through2@0.6.5
237003 silly gentlyRm c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task\node_modules\through2 is being purged from base c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web
237004 verbose gentlyRm don't care about contents; nuking c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task\node_modules\through2
237005 silly vacuum-fs purging c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task\node_modules\through2
237006 silly vacuum-fs quitting because other entries in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task\node_modules
237007 verbose unbuild node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
237008 info preuninstall utf-8-validate@1.1.0
237009 info uninstall utf-8-validate@1.1.0
237010 verbose unbuild rmStuff utf-8-validate@1.1.0 from c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules
237011 verbose unbuild rmStuff in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules
237012 info postuninstall utf-8-validate@1.1.0
237013 silly gentlyRm c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate is being purged from base c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web
237014 verbose gentlyRm don't care about contents; nuking c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
237015 silly vacuum-fs purging c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
237016 silly vacuum-fs quitting because other entries in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules
237017 verbose unbuild node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil
237018 info preuninstall bufferutil@1.1.0
237019 info uninstall bufferutil@1.1.0
237020 verbose unbuild rmStuff bufferutil@1.1.0 from c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules
237021 verbose unbuild rmStuff in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules
237022 info postuninstall bufferutil@1.1.0
237023 silly gentlyRm c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil is being purged from base c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web
237024 verbose gentlyRm don't care about contents; nuking c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil
237025 silly vacuum-fs purging c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\bufferutil
237026 silly vacuum-fs quitting because other entries in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules
237027 verbose unbuild node_modules\gulp-replace-task
237028 info preuninstall gulp-replace-task@0.1.0
237029 info uninstall gulp-replace-task@0.1.0
237030 verbose unbuild rmStuff gulp-replace-task@0.1.0 from c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules
237031 info postuninstall gulp-replace-task@0.1.0
237032 silly gentlyRm c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task is being purged from base c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web
237033 verbose gentlyRm don't care about contents; nuking c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task
237034 silly vacuum-fs purging c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules\gulp-replace-task
237035 silly vacuum-fs quitting because other entries in c:\bamboo-home\xml-data\build-dir\SB-MB-JOB1\Web\node_modules

最佳答案

我遇到了同样的错误......我看到你也在使用竹子。所以。您在使用 Bamboo 的 Node.js Addon 吗?检查设置 -> 插件 -> 查找新插件。

在任务设置中选择类型“NPM”并最大化“高级设置”选项卡。选择“使用独立缓存”。可能是它有点慢,因为它必须将所有内容复制到缓存中,但 Bamboo 正在您的 bamboo 主目录中创建该目录。

从那以后我就没有收到这个错误。对我有用

关于node.js - npm install 在 Windows 上随机失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31926793/

相关文章:

Javascript 异步回调 hell

c# - 获取句柄并写入启动我们进程的控制台

node.js - 由于node-libcurl,命令 npm install 失败

javascript - 如何列出可用的 npm 全局包

node.js - 如何使用 SailsJS 调用 Google API

node.js - AWS Lambda 使用触发器创建函数

c++ - 在 Windows 通用应用程序中使用 curl

node.js - Node 模块 : symlink or not to symlink?

javascript - 序列化多对多查询问题

windows - 设置iis的语言