弹性 beantalk 是否从 package.json 文件运行安装后?

Sha*_*oon 6 node.js elastic-beanstalk

我正在使用弹性 beanstalk 来部署 node.js 应用程序。在我的scripts部分package.json我有:

  "scripts": {
    "start": "node_modules/.bin/coffee server.coffee",
    "test": "NODE_ENV=test node test/runner.js",
    "coverage": "NODE_ENV=test COVERAGE=1 node test/runner.js -R html-cov test/ > ./test/coverage.html",
    "testw": "fswatch -o test src | xargs -n1 -I{} sh -c 'coffeelint src server.coffee ; npm test'",
    "db:drop": "node scripts/drop-tables.js",
    "encryptConfig": "node_modules/.bin/coffee config/encrypt.coffee",
    "decryptConfig": "node_modules/.bin/coffee config/decrypt.coffee",
    "postinstall": "npm run decryptConfig"
  },
Run Code Online (Sandbox Code Playgroud)

npm install似乎工作。但postinstall不执行。这是一个已知的问题?如果是这样,我怎样才能在发布npm install之前执行某些操作npm start

小智 10

我也刚遇到这个问题。我发现postinstall脚本不会运行,但prestart会运行。我的看起来像这样:

"scripts": {
    "start": "node index.js",
    "prestart": "node node_modules/webpack/bin/webpack.js"
}
Run Code Online (Sandbox Code Playgroud)

现在,当我在eb deploy本地运行时,在启动服务器之前正确地捆绑了我的 webpack 内容。


max*_*022 1

我认为您的意思是您正在使用 EB (Elastic Beanstalk) ELB 作为负载均衡器。Elastic Beanstalk 默认情况下正在运行npm start以运行您的应用程序。我建议您在构建过程中将模块与应用程序打包在一起。