Tools: polymer-cli global install error

Created on 3 Aug 2017  路  34Comments  路  Source: Polymer/tools

Description

npm error when running npm install -g polymer-cli as root.

This is done in CI process in a Docker container.

Versions & Environment

  • Polymer CLI: 1.3.1
  • node: 8.2.1
  • npm: 5.3.0
  • Operating System: Debian 8

Steps to Reproduce

To reproduce, build this Dockerfile:

FROM node
RUN npm install -y polymer-cli

Expected Results

NPM should install polymer-cli without an error.

Actual Results

We get an error in the output and the installation exists with error code 1:

> [email protected] 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 Object.fs.mkdirSync (fs.js:891: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: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 info lifecycle [email protected]~install: Failed to exec install script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node scripts/build-browser-scripts`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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!     /root/.npm/_logs/2017-08-02T04_53_27_270Z-debug.log

The log file mentioned in the output says:

...
24890 silly install [email protected]
24891 info lifecycle [email protected]~install: [email protected]
24892 verbose lifecycle [email protected]~install: unsafe-perm in lifecycle false
24893 verbose lifecycle [email protected]~install: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/lib/node_modules/polymer-cli/node_modules/wd/node_modules/.bin:/usr/local/lib/node_modules/polymer-cli/node_modules/.bin:/usr/local/lib/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
24894 verbose lifecycle [email protected]~install: CWD: /usr/local/lib/node_modules/polymer-cli/node_modules/wd
24895 silly lifecycle [email protected]~install: Args: [ '-c', 'node scripts/build-browser-scripts' ]
24896 silly lifecycle [email protected]~install: Returned: code: 1  signal: null
24897 info lifecycle [email protected]~install: Failed to exec install script
24898 verbose unlock done using /root/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
24899 verbose stack Error: [email protected] install: `node scripts/build-browser-scripts`
24899 verbose stack Exit status 1
24899 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
24899 verbose stack     at emitTwo (events.js:125:13)
24899 verbose stack     at EventEmitter.emit (events.js:213:7)
24899 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
24899 verbose stack     at emitTwo (events.js:125:13)
24899 verbose stack     at ChildProcess.emit (events.js:213:7)
24899 verbose stack     at maybeClose (internal/child_process.js:921:16)
24899 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
24900 verbose pkgid [email protected]
24901 verbose cwd /
24902 verbose Linux 4.10.0-29-generic
24903 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "polymer-cli@next"
24904 verbose node v8.2.1
24905 verbose npm  v5.3.0
24906 error code ELIFECYCLE
24907 error errno 1
24908 error [email protected] install: `node scripts/build-browser-scripts`
24908 error Exit status 1
24909 error Failed at the [email protected] install script.
24909 error This is probably not a problem with npm. There is likely additional logging output above.
24910 verbose exit [ 1, true ]

Workarounds:

Using node:6 as the base image, works out fine.

cli

Most helpful comment

I recently ran into this issue and what I can say that fixes it is to do sudo npm install -g polymer-cli --unsafe-perm

All 34 comments

I have the same error on MacOS.

npm -v: 5.3.0
node -v: v8.2.1

Error message:

npm WARN deprecated [email protected]: ..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/[email protected]: See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12826
/usr/local/bin/polymer -> /usr/local/lib/node_modules/polymer-cli/bin/polymer.js

[email protected] 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 Object.fs.mkdirSync (fs.js:891:18)
at sync (/usr/local/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:71:13)
at Object. (/usr/local/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! [email protected] install: node scripts/build-browser-scripts
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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! /Users/pawelpsztyc/.npm/_logs/2017-08-03T23_47_06_896Z-debug.log

This issue is also report here https://github.com/Polymer/polymer-cli/issues/832. Can any of the admins check this? Thanks.

As details in the NPM issue linked above, the problem is a regression in NPM and can be also worked around by setting --unsafe-perm

Wired thing. After I posted my comment I wen't back home. Today I was able to install the cli tool globally without this option. Only thing I did is restart... Another Mac issue then?

A. With or with out sudo?
B. What is your npm version?
C. What does npm config get prefix say?

Closing per https://github.com/Polymer/polymer-cli/issues/832#issuecomment-320238339 Thanks again @guss77 !

I recently ran into this issue and what I can say that fixes it is to do sudo npm install -g polymer-cli --unsafe-perm

I also encountered this issue with the latest npm (5.5.1) and was workarounded by adding --unsafe-perm option as instructed above. Has anyone reported this issue to npm, if it is an issue of npm?

Running sudo npm install -g polymer-cli --unsafe-perm also worked for me. Running node 8.9.4 and npm 5.6.0.

Redic, just troubleshooted the same error. Can you guys (any packages makers), include a setup and getting started guide that works. How can we move forward if every step needs troubleshooting?

+1 Same thing here. Luckily Google found the error message.

sudo npm install -g polymer-cli --unsafe-perm works fine for me to, Running npm: 5.6.0 and
node: 8.11.1

sudo npm install -g polymer-cli --unsafe-perm also worked for me.
npm: 5.6.0
node: 9.10.1

I have the same problem. and I solved by changing npm's Default Directory.
then by running following command without sudo and --unsafe-perm
npm install -g polymer-cli

this is not the issue with polymer-cli, but of node and npm installation location.

sudo npm install -g polymer-cli --unsafe-perm also worked for me.
npm: 5.6.0
node: 8.11.2

thanks

sudo npm install -g polymer-cli --unsafe-perm also worked for me.
npm: 6.1.0
node: 10.4.1

Had the same problem installing polymer-cli on a linux hosted agent in VSTS. --unsafe-perm worked for me. Thanks for the workaround.

--unsafe-perm worked for me. Thanks for the workaround.

why I ever need to do --unsafe-perm on My latest Sierra? It it not so smart as it seems or MacOS support is finally dropped for node/npm developers?

@hack2root you could use nvm ;) and you have all the permissons on the world to make polymer works

sudo npm install -g polymer-cli --unsafe-perm also worked for me.
npm: 6.2.0
node: v8.11.3

Same error, fixed with:
sudo npm install -g polymer-cli --unsafe-perm
npm: 6.2.0
node: v8.0.0
Ubuntu 16.04.5 LTS

--unsafe-perm worked for me too

Why is it closed? This issue is still in Polymer 3...

The workaround works with --unsafe-perm worked for me as well.
MacOs 10.14
Node 10.8.0
NPM 6.2.0

Because this isn't a problem with the polymer-cli, it's caused by permission problems with your npm setup. You can either manually configure permissions after installing npm, or use something like nvm which will do it automatically.

You can either manually configure permissions after installing npm, or use something like nvm which will do it automatically.

Or - better yet, fix the problem in NPM itself, as documented here: https://github.com/npm/npm/issues/17346 . Though by the fact that that bug report is "archived", there's a good indication that NPM maintainers don't intend to fix this problem and consider it "purposefully broken".

Maybe someone would like to open a new bug report about this problem, I personally am no longer invested in the nodejs community, a lot because of attitudes demonstrated in the above linked NPM issue #17346, which is complete indifference to incorrect behavior that does not impact the developer own personal workstation.

You can either manually configure permissions after installing npm, or use something like nvm which will do it automatically.

Or - better yet, fix the problem in NPM itself, as documented here: https://github.com/npm/npm/issues/17346 .

Though by the fact that the npm/npm repository is archived (with thousands of bugs still open), with development moved (unexplained) to another Github repository with no bug tracking - and developers are now expected to file bugs through a Discourse forum posting - all this is a good indication that NPM maintainers aren't really interested in fixing this and other bugs.

Maybe someone would like to re-report this bug here: https://npm.community/c/bugs.

I personally am no longer invested in the nodejs community, a lot because of attitudes demonstrated in the process described here: which is complete indifference to incorrect behavior that does not impact the developer own personal workstation (relegating bug reports to forum posts is basically saying that they don't care about bug reports).

This seem to be the best solution (don't use this on production machine):
https://github.com/Polymer/polymer-cli/issues/828#issuecomment-319842742

The same error I also suffered in Windows 8.1 x86 32-bit.

Error still exists and sudo npm install -g polymer-cli --unsafe-perm still fixes it.

Using the option
--unsafe-perm
works fine with me to solve the permission denied issue..

node 13.7.0
npm 6.13.6
ubuntu 18.04.3 LTS

--unsafe-perm still seems to work

--unsafe-perm didn't work for me. The problem was that I had no permissions in the folder, so I used:
sudo chown -R myuser:myuser .
and it solved the problem

Was this page helpful?
0 / 5 - 0 ratings