6

I am using elastic beanstalk to deploy a node.js app. In my scripts section of package.json I have:

  "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"
  },

The npm install seems to work. But the postinstall does not execute. Is this a known issue? If so, how can I execute something post npm install but before npm start?

Shamoon
  • 911
  • 4
  • 14
  • 22

2 Answers2

10

I've just come across this problem too. I found that a postinstall script would not run but a prestart would. Mine looks like this:

"scripts": {
    "start": "node index.js",
    "prestart": "node node_modules/webpack/bin/webpack.js"
}

That now correctly bundles my webpack stuff before starting the server when I run eb deploy locally.

Clarkie
  • 201
  • 2
  • 6
1

I think you meant that you are using EB (Elastic Beanstalk) ELB being the load balancer. Elastic Beanstalk is running npm start by default to run your application. I recommend you to package your modules with your application in your build process.

maxwell2022
  • 253
  • 4
  • 11