npm安装在Windows上随机失败

Bra*_*ino 5 windows node.js npm

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

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.
Run Code Online (Sandbox Code Playgroud)

即使该命令在以管理员身份运行的命令提示符中以管理员身份执行.命令失败的程序包每次都会变化,而其他Windows计算机在npm install使用相同的源运行时不会出现此问题.

我已经尝试npm cache clean并手动删除C:\ Users \%username%\ AppData \npm-cache目录中的内容而没有运气.我还检查了npm-cache目录,NodeJS安装目录和包含源代码checkout的目录的权限,并且都显示管理员组具有完全权限,并且admin用户(运行该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
Run Code Online (Sandbox Code Playgroud)

小智 0

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

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

从那时起我就没有收到此错误。对我有用