rohan kapoor
rohan kapoor

Reputation: 311

serverless: command not found in ubuntu 16.04

I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: npm install -g serverless in the terminal. But when I try to run serverless it returns an error saying serverless: command not found. Below is a screenshot for reference:

Command not found error

Upvotes: 31

Views: 62160

Answers (6)

tw1742
tw1742

Reputation: 1484

Another option, following this post, is to try npx serverless ...

Upvotes: 1

Riddhi Sanyal
Riddhi Sanyal

Reputation: 473

If the above options are not working (due to insufficient access or sudo access), following one will definitely work as it's saving the serverless into your local.

npm install serverless --save-dev
node ./node_modules/serverless/bin/serverless deploy

Reference link - https://serverless.com/framework/docs/providers/aws/guide/services/

Upvotes: 13

Was getting the same error serverless: command not found but instead of NPM was using YARN. To fix it had to execute (or better add to your ~/.bash_profile):

export PATH="$PATH:$(yarn global bin)"

then, if not already installed:

yarn global add serverless

Upvotes: 12

vgaltes
vgaltes

Reputation: 1218

my recomendation here is to allways install the serverless framework as a dev dependency (npm install serverless --save-dev) specially if you're working in a team where each member can have its own version of the framework. After that, you can call the framework using npm scripts. For example, you can create a new entry in the scripts section like this: "deploy" : "serverless deploy" and call it using npm run deploy.

Upvotes: 9

Mahmudul Haque Azad
Mahmudul Haque Azad

Reputation: 73

Try with the following order

npm config set prefix /usr/local

sudo npm i -g serverless

sudo /usr/bin/node /usr/local/lib/node_modules/serverless/node_modules/tabtab/src/cli.js install --name serverless --auto

Upvotes: 4

Manoj
Manoj

Reputation: 2442

Try running,

npm config set prefix /usr/local

and then,

npm i -g serverless

Upvotes: 81

Related Questions