Search code examples
meteornpmmeteor-up

Error when deploying a meteor app using mup deploy while npm install bcrypt


I have an error when deploying a meteor app using mup deploy, well, in fact, I also get this error when I manually try to build the image with the Dockerfile generated by mup.

I guess the main error message (somewhere below in the log output) is:

sh: 1: node-pre-gyp: not found

Log output from docker build -t my-app:build .:

Removing intermediate container 3ac4d1150023
Step 7/7 : RUN cd  /built_app/programs/server &&     npm install --unsafe-perm
 ---> Running in 4a6faacefc21

> [email protected] install /built_app/programs/server/node_modules/fibers
> node build.js || nodejs build.js

`linux-x64-v8-4.5` exists; testing
Binary is fine; exiting

> [email protected] install /built_app/programs/server
> node npm-rebuild.js


> [email protected] install /built_app/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt
> node-gyp rebuild

make: Entering directory '/built_app/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
  SOLINK_MODULE(target) Release/obj.target/bcrypt_lib.node
  COPY Release/bcrypt_lib.node
make: Leaving directory '/built_app/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/build'
[email protected] /built_app/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt
[email protected] /built_app/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/node_modules/bindings
[email protected] /built_app/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/node_modules/nan

> [email protected] install /built_app/programs/server/npm/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] install 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!     /root/.npm/_logs/2018-02-07T17_21_17_486Z-debug.log
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node npm-rebuild.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install 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!     /root/.npm/_logs/2018-02-07T17_21_17_559Z-debug.log
The command '/bin/sh -c cd  /built_app/programs/server &&     npm install --unsafe-perm' returned a non-zero code: 1

And the mentioned log files says:

...
1227 info build /built_app/programs/server/npm/node_modules/bcrypt
1228 info lifecycle [email protected]~preinstall: [email protected]
1229 silly lifecycle [email protected]~preinstall: no script for preinstall, continuing
1230 info linkStuff [email protected]
1231 silly linkStuff [email protected] has /built_app/programs/server/npm/node_modules as its parent node_modules
1232 verbose linkBins [email protected]
1233 verbose linkMans [email protected]
1234 verbose rebuildBundles [email protected]
1235 info lifecycle [email protected]~install: [email protected]
1236 verbose lifecycle [email protected]~install: unsafe-perm in lifecycle true
1237 verbose lifecycle [email protected]~install: PATH: /opt/nodejs/lib/node_modules/npm/bin/node-gyp-bin:/built_app/programs/server/npm/node_modules/bcrypt/node_modules/.bin:/built_app/programs/server/npm/node_modules/.bin:/opt/nodejs/bin:/opt/nodejs/lib/node_modules/npm/bin/node-gyp-bin:/built_app/programs/server/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
1238 verbose lifecycle [email protected]~install: CWD: /built_app/programs/server/npm/node_modules/bcrypt
1239 silly lifecycle [email protected]~install: Args: [ '-c', 'node-pre-gyp install --fallback-to-build' ]
1240 info lifecycle [email protected]~install: Failed to exec install script
1241 verbose stack Error: [email protected] install: `node-pre-gyp install --fallback-to-build`
1241 verbose stack spawn ENOENT
1241 verbose stack     at ChildProcess.<anonymous> (/opt/nodejs/lib/node_modules/npm/lib/utils/spawn.js:33:16)
1241 verbose stack     at emitTwo (events.js:87:13)
1241 verbose stack     at ChildProcess.emit (events.js:172:7)
1241 verbose stack     at maybeClose (internal/child_process.js:862:16)
1241 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:222:5)
1242 verbose pkgid [email protected]
1243 verbose cwd /built_app/programs/server/npm
1244 verbose Linux 4.4.0-83-generic
1245 verbose argv "/opt/nodejs/bin/node" "/opt/nodejs/bin/npm" "rebuild"
1246 verbose node v4.8.7
1247 verbose npm  v4.6.1
1248 error file sh
1249 error code ELIFECYCLE
1250 error errno ENOENT
1251 error syscall spawn
1252 error [email protected] install: `node-pre-gyp install --fallback-to-build`
1252 error spawn ENOENT
1253 error Failed at the [email protected] install script.
1253 error This is probably not a problem with npm. There is likely additional logging output above.
1254 verbose exit [ 1, true ]

meteor version: 1.4.4.2
node version: v4.8.7 npm version: 4.6.1
mup version: 1.3.7
docker image: abernix/meteord:node-4.8.7-base

Any idea ...?
Which file is not found?
(And, I'm pretty sure that exactly the same config was working some while ago ...)
I really appreciate any suggestion!


Solution

  • Your app start needs node-pre-gyp because of bcrypt package:

    > [email protected] install /built_app/programs/server/npm/node_modules/bcrypt

    > node-pre-gyp install --fallback-to-build

    However if you pay close attention, you will notice just above that another version of bcrypt is also installed and builds successfully:

    > [email protected] install /built_app/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt

    > node-gyp rebuild

    Given the installation paths, it seems that 0.8.6 probably comes from a Meteor Atmosphere package (npm-bcrypt), while 1.0.3 comes from package.json dependencies.

    Therefore you should probably first try to sort out why you have 2 different installations of bcrypt, and if you can get rid of the 1.0.3 version.

    In the most likely case that your app depends on bcrypt because of Meteor's accounts-password package, the latter will use a JavaScript version of bcrypt instead automatically if it is missing, so your app should not break by simply removing the npm version: meteor npm uninstall --save bcrypt (as mentioned by @AbhishekMaurya). However, as noted by @AbhishekMaurya's answer, the app start log will display a warning message suggesting to npm install bcrypt (which you have just undone). You can live with that warning if you accept the slight degradation in performance when your app uses the JavaScript implementation of bcrypt.

    As for the root cause now, there was a bug in Meteor that prevented node-pre-gyp being visible to npm. This should have been fixed in Meteor version 1.4.3.

    If not, you can try to make sure you use an "old" version of bcrypt, as mentioned here: meteor npm install --save [email protected]