Npm 如何在macOS中配置和使用无服务器脱机?

Npm 如何在macOS中配置和使用无服务器脱机?,npm,package.json,serverless-framework,serverless-offline,Npm,Package.json,Serverless Framework,Serverless Offline,我正在尝试使用无服务器脱机库,使用无服务器框架, 我已经正确配置了serverless.yaml文件,其中- plugins: - serverless-offline 添加到它。 以下是my package.json- { "name": "serverless-test", "version": "1.0.0", "description": "Lambda APIs for Test Module", "main": "index.js", "scripts":

我正在尝试使用无服务器脱机库,使用无服务器框架,
我已经正确配置了serverless.yaml文件,其中-

plugins:
  - serverless-offline
添加到它。

以下是my 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
bash: sls: command not found
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 ]
我使用以下命令安装软件包-

{
  "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
bash: sls: command not found
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 ]
也运行-

npm i dev
并离线运行sls和无服务器离线运行 运行脱机模式。

但我收到以下错误-

{
  "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
bash: sls: command not found
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 ]

我检查了npm日志,发现了这个-

{
  "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
bash: sls: command not found
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上无法这样做,

有什么解决办法吗?

您的问题不在于
无服务器离线
插件,而在于:它并没有安装,所以您得到了

找不到sls(或无服务器)命令


只需运行
npm安装serverless-g
。请记住,根据您如何设置
npm
,您可能需要
sudo
权限才能全局安装软件包。

我正在尝试在mac上安装无服务器脱机插件,如何验证安装?