简体   繁体   中英

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:

找不到命令错误

Try running,

npm config set prefix /usr/local

and then,

npm i -g serverless

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/

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

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 .

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM