我正在尝试通过无服务器框架使用无服务器离线库,
我使用-
plugins:
- serverless-offline
已添加到其中。
以下是我的package.json-
{
"name": "serverless-test",
"version": "1.0.0",
"description": "Lambda APIs for Test Module",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "./node_modules/.bin/serverless offline -s dev",
"debug": "export SLS_DEBUG=* && node --debug ./node_modules/.bin/serverless offline -s dev"
},
"author": "Aniruddha",
"license": "ISC",
"dependencies": {
"async": "^2.6.2",
"aws-sdk": "^2.447.0",
"axios": "^0.18.0",
"jsonwebtoken": "^8.5.1",
"moment": "^2.24.0",
"moment-timezone": "^0.5.25",
"mysql": "^2.17.1"
},
"devDependencies": {
"serverless-offline": "4.9.4"
}
}
我使用以下命令安装软件包-
npm i
也跑了-
npm i dev
然后运行sls offline
和serverless offline
运行脱机模式。
但是我遇到了以下错误-
bash: sls: command not found
和
bash: serveless: command not found
我检查了npm日志并找到了-
112 error code EBADPLATFORM
113 error notsup Unsupported platform for inotify@1.4.6: wanted {"os":"linux","arch":"any"} (current: {"os":"darwin","arch":"x64"})
114 error notsup Valid OS: linux
114 error notsup Valid Arch: any
114 error notsup Actual OS: darwin
114 error notsup Actual Arch: x64
115 verbose exit [ 1, true ]
我可以在ubuntu上使用无服务器脱机罚款,
但在Mac上无法做到,
有解决办法吗?
答案 0 :(得分:0)
您的问题不是serverless offline
插件,而是Serverless Framework插件:未安装,因此您得到
找不到sls(或无服务器)命令
只需运行npm install serverless -g
。请记住,取决于您如何设置npm
,您可能需要sudo
权限才能全局安装软件包。