tools: polymer-cli global install error
Description
npm error when running sudo npm install -g polymer-cli
Versions & Environment
- node: 6.2.2
- Operating System: OS X 10.11.6 (El Capitan)
- npm: 5.3.0
Steps to Reproduce
run sudo npm install -g polymer-cli
Expected Results
polymer-cli is installed
Actual Results
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 please help to create it: https://github.com/bower/bower/issues/2467 npm WARN deprecated @types/assert@0.0.29: See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12826 /usr/local/bin/polymer -> /usr/local/lib/node_modules/polymer-cli/bin/polymer.js
wd@1.4.0 install /usr/local/lib/node_modules/polymer-cli/node_modules/wd node scripts/build-browser-scripts
/usr/local/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:90 throw err0; ^
Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/polymer-cli/node_modules/wd/build’
at Error (native)
at Object.fs.mkdirSync (fs.js:916:18)
at sync (/usr/local/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:71:13)
at Object.<anonymous> (/usr/local/lib/node_modules/polymer-cli/node_modules/wd/scripts/build-browser-scripts.js:6:1)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wd@1.4.0 install: node scripts/build-browser-scripts
npm ERR! Exit status 1
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18
I figured out what was happening: the owner of my /usr/local/lib/node_modules directory was root which is why I got into the habit of running sudo anytime I wanted to do a global npm install.
Changing the ownership to the current user
sudo chown -R $(whoami) /usr/local/lib/node_modulesfixed the issue - I can now install successfully without running sudo:npm install -g polymer-cliI’m not quite sure why this just popped up; the error was triggered by the wd package installation process (the wd package is a dependency of polymer-cli). The wd installation script executes
mkdirp(__dirname + '/../build');and must not have been running with root permissions.wdis the culrpit for sure,--unsafe-permhelpshttps://pbs.twimg.com/media/CHKb0FSUwAIZqy5.jpg
This directory is created by the installation process - it doesn’t exist before running
npm.I don’t believe there is actually a permission problem as the process is run using root permissions (this is the docker way), but the actual permissions are:
drwxr-xr-x 1 root root