Node 6.2.1, Linux 4.1.19 debian, gcc 4.9.2, build-essential 11.7, Python 2.7.9
https://gist.github.com/shrikrishnaholla/5674d9b846b0a46cb4302a0b75139b14
The bcrypt build script fails with Cannot find module 'nan', even when nan is globally installed. Works with node v5.11.1, everything else being same.
Same here, running on Ubuntu inside Docker:
FROM jedisct1/phusion-baseimage-latest
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -yq nodejs python # && npm install -g node-gyp
RUN npm install bcrypt
resulting in:
> [email protected] install /node_modules/bcrypt
> node-gyp rebuild
module.js:442
throw err;
^
Error: Cannot find module 'nan'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at [eval]:1:1
at Object.exports.runInThisContext (vm.js:54:17)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:541:32)
at node.js:311:29
at _combinedTickCallback (internal/process/next_tick.js:67:7)
npm-debug.log: https://gist.github.com/leyyinad/3db550282e9526133fc1a29f84482bcd
Solved it by manually installing nan into the correct subdir, like
cd $(npm root -g)/npm && npm install nan
Not the most beautiful, but does the trick for me.
cd $(npm root -g)/npm && npm install nan
So npm is missing a dependency? I don't get it, why does installing something into npm's node_modules fix this problem? @leyyinad how did you figure this out? It is working for me as well...
I have no idea. I just figured the package was missing and played around a bit. By quickly searching npm's repository I don't see any (even missing) dependency on nan. node-gyp lists nan under devDependencies, could this be the reason?
It must be node-gyp, as the command that throws the error is node-gyp's. But then, installing nan in npm's node_modules has fixed this. It's crazy
Edit:
https://github.com/ncb000gt/node.bcrypt.js/blob/master/binding.gyp#L11
Nan must be installed locally I believe for this to work. Closing because the package.json should be installing nan so I don't think there is an issue with the module but instead maybe a transient network or install issue that happened. If you find that there is an issue with the module please file a new issue with recommendations on a fix. Thanks!
I have the same error when I do npm install on windows 7. latest npm and node.js
@leyyinad I installed nan under my npm global folder, it does not work. C:\Users\nliu\AppData\Roamingnpmnode_modules
module.js:471
throw err;
^
Error: Cannot find module 'number-is-nan'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/index.js:2:19)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
if any command at all starts or has anything to do with 'npm' it throws this error
2020 and this works for me.
Solved it by manually installing
naninto the correct subdir, likecd $(npm root -g)/npm && npm install nanNot the most beautiful, but does the trick for me.
Most helpful comment
Solved it by manually installing
naninto the correct subdir, likeNot the most beautiful, but does the trick for me.