部署无服务器应用程序时找不到模块自动完成

时间:2018-10-25 15:05:10

标签: amazon-web-services npm deployment serverless

我一直在尝试使用无服务器部署命令来部署Java应用程序。但是我收到了奇怪的错误:

internal/modules/cjs/loader.js:589
    throw err;
    ^

Error: Cannot find module '../lib/utils/autocomplete'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)
    at Function.Module._load (internal/modules/cjs/loader.js:513:25)
    at Module.require (internal/modules/cjs/loader.js:643:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/codebuild/output/src042580792/src/node_modules/.bin/serverless:5:22)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@1.0.0 deploy: `serverless deploy "--stage" "staging"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-app@1.0.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

现在我一直在使用最新的1.32.0无服务器,而我的package.json看起来像这样:

{
  "name": "my-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "request": "^2.87.0",
    "serverless": "^1.32.0",
    "serverless-sam": "^0.1.0"
  },
  "devDependencies": {
    "serverless-offline": "^3.25.4"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "deploy": "node_modules/.bin/serverless deploy"
  },
  "author": "privatejava",
  "license": "ISC"
}

1 个答案:

答案 0 :(得分:1)

rm -rf node_modules/
npm install

为我解决。