简体   繁体   English

无服务器:在 ubuntu 16.04 中找不到命令

[英]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

Another option, following this post , is to try npx serverless...在这篇文章之后的另一种选择是尝试npx serverless...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未找到无服务器命令“调用测试”。 运行“无服务器帮助”以获取所有可用命令的列表 - Serverless command "invoke test" not found. Run "serverless help" for a list of all available commands 无服务器部署 - Function 未找到 - sls 部署 - Serverless deploy - Function not found - sls deploy 无服务器框架 - 在“自我”源中找不到值 - Serverless Framework - Value not found at "self" source 无服务器框架命令不起作用:“sls deploy -v” - serverless framework command not working: "sls deploy -v" 未找到无服务器插件“无服务器离线”。 确保它已安装并列在无服务器配置文件的“插件”部分 - Serverless plugin "serverless-offline" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file AWS EC2 Ubuntu 16.04 64bit 中 memory 的 VS Code 远程连接 - VS Code remote connection out of memory in AWS EC2 Ubuntu 16.04 64bit 如何在没有参数的情况下运行 do.net lambda deploy-serverless 命令? - How to run `dotnet lambda deploy-serverless` command without parameters? pocketbase:找不到命令 - pocketbase: command not found Composer:在 Mac 上找不到命令 - Composer: Command Not Found on Mac zsh:找不到命令:firebase - zsh: command not found: firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM