CharlieHess/node-mac-notifier

Cannot find module 'nan'

ktiedt opened this issue ยท 6 comments

npm install nan fixes this, but seems like it should be unnecessary?

$ npm install node-mac-notifier
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead

> node-mac-notifier@0.0.13 install /Users/karl.tiedt/Projects/polymer-2-electron-example/node_modules/node-mac-notifier
> node-gyp rebuild

module.js:540
    throw err;
    ^

Error: Cannot find module 'nan'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at [eval]:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at Object.runInThisContext (vm.js:139:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:643:30)
    at evalScript (bootstrap_node.js:462:27)
gyp: Call to 'node -e "require('nan')"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/karl.tiedt/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 17.4.0
gyp ERR! command "/Users/karl.tiedt/.nvm/versions/node/v8.9.4/bin/node" "/Users/karl.tiedt/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/karl.tiedt/Projects/polymer-2-electron-example/node_modules/node-mac-notifier
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-mac-notifier@0.0.13 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-mac-notifier@0.0.13 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

same to me :(

Yeah, I'm keeping both nan and node-gyp as devDependencies.

@CharlieHess

Yeah, I'm keeping both nan and node-gyp as devDependencies.

Why? It creates headaches for your users. Aren't you just defeating the purpose of the dependency mechanism?

  • I added const notifier = require('node-mac-notifier'); resulted in the above error, as my IDE automatically runs npm install for missing modules.
  • I ran npm install node-mac-notifier exactly as your README says, and I get
> node-mac-notifier@1.1.0 install /Users/vas/Repos/projects/corner-pocket/node_modules/node-mac-notifier
> node-gyp rebuild

internal/modules/cjs/loader.js:651
    throw err;
    ^

Error: Cannot find module 'nan'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
    at Function.Module._load (internal/modules/cjs/loader.js:575:25)
    at Module.require (internal/modules/cjs/loader.js:705:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at [eval]:1:1
    at Script.runInThisContext (vm.js:124:20)
    at Object.runInThisContext (vm.js:314:38)
    at Object.<anonymous> ([eval]-wrapper:9:26)
    at Module._compile (internal/modules/cjs/loader.js:799:30)
    at evalScript (internal/process/execution.js:60:25)
gyp: Call to 'node -e "require('nan')"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/Cellar/node/11.12.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/vas/Repos/projects/corner-pocket/node_modules/node-mac-notifier
gyp ERR! node -v v11.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN 538@1.0.0 No description
npm WARN 538@1.0.0 No repository field.
npm WARN 538@1.0.0 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-mac-notifier@1.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-mac-notifier@1.1.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!     /Users/vas/.npm/_logs/2019-04-02T21_44_32_708Z-debug.log

Agreed, these are obviously dependencies and I don't see why you would keep them as devdependencies...

I tried to use this library today, but it won't install without the listed nan dependency. I'm not going to manually manage multiple dependencies as that defeats the purpose of listing deps. :(

For newbies, to solve this issue please install missing dependencies, and so:

npm install nan node-gyp

and now you can install the package:

npm install node-mac-notifier 

or using Yarn:

yarn add nan node-gyp
yarn add node-mac-notifier