Search code examples
node.jsnpmbrunchnpm-scripts

brunch build --production fails only in production


Out of the blue build script started to fail. No changes in environment or configs at all. Works fine in dev, fails in prod.

Both dev and prod (both Ubuntus):

$ npm -v
5.3.0
$ node -v
v6.11.2

In dev:

oleg@DevVM ~/Code/loaded.bike/assets $ npm run deploy

> @ deploy /home/oleg/Code/loaded.bike/assets
> brunch build --production

17:49:59 - info: compiling
17:49:59 - info: compiled 19 files into 2 files, copied 32 in 6.9 sec

In prod:

deploy@loaded-bike-app:~/builds/assets$ npm run deploy

> @ deploy /home/deploy/builds/assets
> brunch build --production

00:45:30 - error: Initialization error - Could not load global module 'jquery'. Possible solution: add 'jquery' to package.json and `npm install`. Could not load global module 'jquery'. Possible solution: add 'jquery' to package.json and `npm install`.
Stack trace was suppressed. Run with `LOGGY_STACKS=1` to see the trace. 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ deploy: `brunch build --production`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/deploy/.npm/_logs/2017-08-12T00_45_30_084Z-debug.log

Full log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'deploy' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle @~predeploy: @
6 info lifecycle @~deploy: @
7 verbose lifecycle @~deploy: unsafe-perm in lifecycle true
8 verbose lifecycle @~deploy: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/deploy/builds/assets/node_modules/.bin:/home/deploy/bin:/home/deploy/.local
/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle @~deploy: CWD: /home/deploy/builds/assets
10 silly lifecycle @~deploy: Args: [ '-c', 'brunch build --production' ]
11 silly lifecycle @~deploy: Returned: code: 1  signal: null
12 info lifecycle @~deploy: Failed to exec deploy script
13 verbose stack Error: @ deploy: `brunch build --production`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
13 verbose stack     at emitTwo (events.js:106:13)
13 verbose stack     at EventEmitter.emit (events.js:191:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
13 verbose stack     at emitTwo (events.js:106:13)
13 verbose stack     at ChildProcess.emit (events.js:191:7)
13 verbose stack     at maybeClose (internal/child_process.js:891:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
14 verbose pkgid @
15 verbose cwd /home/deploy/builds/assets
16 verbose Linux 4.8.0-41-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
18 verbose node v6.11.2
19 verbose npm  v5.3.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ deploy: `brunch build --production`
22 error Exit status 1
23 error Failed at the @ deploy script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Adding jquery, tether to package.json fixes require error but then it just chokes on sass compile. Is this just JS missfiring async function out of order or what is going here? Once again, it started to fail completely out of the blue. Deployed just fine yesterday and today if fails without me changing anything. Any clue what might be wrong here?

EDIT:

package.json:

{
  "repository": {},
  "license": "MIT",
  "scripts": {
    "deploy": "brunch build --production",
    "watch": "brunch watch --stdin"
  },
  "dependencies": {
    "bootstrap": "^4.0.0-alpha.6",
    "phoenix": "file:../deps/phoenix",
    "phoenix_html": "file:../deps/phoenix_html"
  },
  "devDependencies": {
    "babel-brunch": "6.0.6",
    "brunch": "2.10.10",
    "clean-css-brunch": "2.10.0",
    "css-brunch": "2.10.0",
    "sass-brunch": "2.10.4",
    "uglify-js-brunch": "2.1.1"
  }
}

I'm actually seeing this crap on prod (but not on dev)

npm ERR! peer dep missing: jquery@>=3.0.0, required by [email protected]
npm ERR! peer dep missing: popper.js@^1.11.0, required by [email protected]

What is that about? Bootstrap defines those as dependencies (not peerDependency) in its own package.json. npm doesn't pull in dependencies now?


Solution

  • "bootstrap": "^4.0.0-alpha.6"
    

    Needed to lock the version. Bootstrap went from alpha.6 to beta yesterday. Messed everything up. No idea why is started to fail only on one machine (even after npm cache clear). Sass compile fails under beta, so I locked it to alpha.6 for now.

    I think I need to start locking dependency versions. This took way too long to figure out.