Pipelines: Permission Denied on Global NPM Install

Justin Ellison May 8, 2018

Attempting to install a global NPM package, for example @angular/cli, results in a permission denied error.

The pipelines configuration is pretty simple:

image: atlassian/default-image:2pipelines: custom: production: - step: name: Build & Deploy Project deployment: production script: - npm install -g @angular/cli@6.0.0 - npm install -g gulp-cli - cd web/web.cmor - npm install - gulp prod - ng build --prod

The resulting failure reads like this:

npm install -g @angular/cli@6.0.0/root/.nvm/versions/node/v8.9.4/bin/ng -> /root/.nvm/versions/node/v8.9.4/lib/node_modules/@angular/cli/bin/ng> @angular/cli@6.0.0 postinstall /root/.nvm/versions/node/v8.9.4/lib/node_modules/@angular/cli> node ./bin/ng-update-message.jssh: 1: node: Permission deniednpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules/@angular/cli/node_modules/fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})npm ERR! file shnpm ERR! code ELIFECYCLEnpm ERR! errno ENOENTnpm ERR! syscall spawnnpm ERR! @angular/cli@6.0.0 postinstall: `node ./bin/ng-update-message.js`npm ERR! spawn ENOENTnpm ERR! npm ERR! Failed at the @angular/cli@6.0.0 postinstall 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/2018-05-08T16_23_15_479Z-debug.log

2 answers

1 vote
James Nuanez January 6, 2021

The best way I found to install NPM packages globally with Bitbucket Pipelines was to set the user to root:

script:
- npm -g config set user root
- npm install -g packagename

Source: https://stackoverflow.com/a/54290720/8742362 

0 votes
Jeroen De Raedt
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 21, 2018

Hi @Justin Ellison,

I had a look around and maybe this article could help? https://github.com/npm/npm/issues/14042

Andrii_Chumak December 11, 2018

Dead link...

Lalit Indoria May 22, 2019

I'm facing the same error and it has started happening very recently. Any luck @Andrii_Chumak  ?

Jeroen De Raedt
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2019

@Andrii_Chumak I updated the link, could you check again? 

Andrii_Chumak May 23, 2019

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events