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
> fibers@1.0.13 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
> meteor-dev-bundle@0.0.0 install /built_app/programs/server
> node npm-rebuild.js
> bcrypt@0.8.6 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'
bcrypt@0.8.6 /built_app/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt
bindings@1.2.1 /built_app/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/node_modules/bindings
nan@2.2.1 /built_app/programs/server/npm/node_modules/meteor/npm-bcrypt/node_modules/bcrypt/node_modules/nan
> bcrypt@1.0.3 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! bcrypt@1.0.3 install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the bcrypt@1.0.3 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 meteor-dev-bundle@0.0.0 No description
npm WARN meteor-dev-bundle@0.0.0 No repository field.
npm WARN meteor-dev-bundle@0.0.0 No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! meteor-dev-bundle@0.0.0 install: `node npm-rebuild.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the meteor-dev-bundle@0.0.0 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 bcrypt@1.0.3~preinstall: bcrypt@1.0.3
1229 silly lifecycle bcrypt@1.0.3~preinstall: no script for preinstall, continuing
1230 info linkStuff bcrypt@1.0.3
1231 silly linkStuff bcrypt@1.0.3 has /built_app/programs/server/npm/node_modules as its parent node_modules
1232 verbose linkBins bcrypt@1.0.3
1233 verbose linkMans bcrypt@1.0.3
1234 verbose rebuildBundles bcrypt@1.0.3
1235 info lifecycle bcrypt@1.0.3~install: bcrypt@1.0.3
1236 verbose lifecycle bcrypt@1.0.3~install: unsafe-perm in lifecycle true
1237 verbose lifecycle bcrypt@1.0.3~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 bcrypt@1.0.3~install: CWD: /built_app/programs/server/npm/node_modules/bcrypt
1239 silly lifecycle bcrypt@1.0.3~install: Args: [ '-c', 'node-pre-gyp install --fallback-to-build' ]
1240 info lifecycle bcrypt@1.0.3~install: Failed to exec install script
1241 verbose stack Error: bcrypt@1.0.3 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 bcrypt@1.0.3
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 bcrypt@1.0.3 install: `node-pre-gyp install --fallback-to-build`
1252 error spawn ENOENT
1253 error Failed at the bcrypt@1.0.3 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!
Your app start needs node-pre-gyp
because of bcrypt
package:
> bcrypt@1.0.3 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:
> bcrypt@0.8.6 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 bcrypt@0.8.7