Permission Denied after successful npm install

This is related to the following: Yarn: Permission denied

We run sudo npm install -g serverless in an earlier step and then get randomly hit with bash permission denials like this:

There is no consistency behind the failures and can be easily resolved by a re-run. Obviously this isn’t ideal as it distracts our dev team. Has anyone found solutions to this?

1 Like

Hello @djakaitis,

Welcome to the forum.

Was serverless installed as a global npm module?
npm install -g serverless

You will need to install CLI tools as global modules to use them directly. Otherwise you could point to serverless via
.node_modules/.../sls package

Let us know how it works out :+1:

1 Like

@KyleTryon Yes – sorry I missed the -g flag in my original post. We are installing globally.

Installing the npm module globally should also mean that using the binary would require sudo no? As in:

sudo sls package

This wouldn’t explain why it sometimes works though.

Was this issue ever solved?

We are installing Serverless with

sudo npm install -g serverless

and also seeing this intermittent error when calling sls deploy subsequently.