无论我尝试什么,每次我尝试安装 polymer-cli 时,总是会出现 PERMISSION_DENIED 错误。
bradley@gurulaptop:~$ sudo npm -g install polymer-cli
npm WARN deprecated bower@1.8.0: ..psst! While Bower is maintained, we recommend Yarn and Webpack for *new* front-end projects! Yarn's advantage is security and reliability, and Webpack's is support for both CommonJS and AMD projects. Currently there's no migration path but we hope you'll help us figure out one.
npm WARN deprecated @types/assert@0.0.29: See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12826
/usr/bin/polymer -> /usr/lib/node_modules/polymer-cli/bin/polymer.js
> wd@1.2.0 install /usr/lib/node_modules/polymer-cli/node_modules/wd
> node scripts/build-browser-scripts
/usr/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:90
throw err0;
^
Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/polymer-cli/node_modules/wd/build'
at Object.fs.mkdirSync (fs.js:877:18)
at sync (/usr/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:71:13)
at Object.<anonymous> (/usr/lib/node_modules/polymer-cli/node_modules/wd/scripts/build-browser-scripts.js:6:1)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wd@1.2.0 install: `node scripts/build-browser-scripts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wd@1.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/bradley/.npm/_logs/2017-06-06T13_10_23_400Z-debug.log
我该如何解决这个问题?
最佳答案
我遇到了同样的问题并遵循@Tim Lundqvist的回答并通过以下方式解决:
第一步:在 home 中创建一个隐藏文件夹。命令:
$ cd ~
$ mkdir .polymer-patch
$ cd .polymer-patch
$ npm install polymer-cli
第二步:创建符号链接(symbolic link)以使其可执行
$ sudo ln -s "$(readlink -f ~/.polymer-patch/node_modules/.bin/wd)" /usr/bin/wd
$ sudo ln -s "$(readlink -f ~/.polymer-patch/node_modules/.bin/polymer)" /usr/bin/polymer
$ polymer
现在polymer CLI正在为我工作。
更新
这个问题是
node
和 npm
版本相关,但以下命令效果很好$ sudo npm install --unsafe-perm -g polymer-cli
关于Ubuntu上的polymer-cli安装失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44391110/