[英]serverless: command not found in ubuntu 16.04
I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS.我正在尝试在 Ubuntu 16.04 LTS 中设置 AWS 无服务器框架。 I installed Node.js and have also installed Serverless using the following command:
npm install -g serverless
in the terminal.我安装了 Node.js,还使用以下命令安装了 Serverless:在终端中执行
npm install -g serverless
。 But when I try to run serverless
it returns an error saying serverless: command not found
.但是当我尝试运行无服务器时,它会返回一条错误消息,指出
serverless
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.如果上述选项不起作用(由于访问权限不足或 sudo 访问权限不足),则以下选项肯定会起作用,因为它将无服务器保存到您的本地。
npm install serverless --save-dev
node ./node_modules/serverless/bin/serverless deploy
Reference link - https://serverless.com/framework/docs/providers/aws/guide/services/参考链接 - 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.得到同样的错误serverless: command not found但不是 NPM 而是使用 YARN。 To fix it had to execute (or better add to your ~/.bash_profile):
要修复它必须执行(或更好地添加到您的 ~/.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.我在这里的建议是始终将无服务器框架安装为开发依赖项(
npm install serverless --save-dev
),特别是如果您在一个团队中工作,每个成员都可以拥有自己的框架版本。 After that, you can call the framework using npm scripts.之后,您可以使用 npm 脚本调用框架。 For example, you can create a new entry in the scripts section like this:
"deploy": "serverless deploy"
and call it using npm run deploy
.例如,您可以在脚本部分创建一个新条目,如下所示:
"deploy": "serverless deploy"
并使用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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.