I had install module mongoskin
(sudo npm install mongoskin -g
) - success install.
When i try to start my index.js
with (supervisor index.js
), there's this error:
module.js:340
throw err;
^
Error: Cannot find module 'mongoskin'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/Users/smithua/Documents/uezo.pro/dnode-node/im.js:5:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
DEBUG: Program node index.js exited with code 8
ls -la /usr/local/lib/node_modules/
:
0 drwxr-xr-x 14 smithua staff 476 Jul 30 18:53 dnode
0 drwxr-xr-x 7 smithua staff 238 Jul 31 11:40 jshint
0 drwxr-xr-x 10 smithua staff 340 Jul 31 11:00 jslint
0 drwxr-xr-x 17 smithua staff 578 Aug 12 16:48 mongoskin
0 drwxr-xr-x 15 smithua staff 510 Jul 30 16:40 mysql
0 drwxr-xr-x 20 smithua staff 680 Jul 31 11:09 npm
0 drwxr-xr-x 19 smithua staff 646 Jul 31 03:56 promised-io
0 drwxr-xr-x 6 smithua staff 204 Jul 30 16:40 supervisor
You have to install the module locally, not globally. That means you must NOT use the -g
option when installing using npm.
In Node.js, basically each application needs to have all of its dependencies in a local node_modules
folder. You achieve this by installing node-mongoskin using:
$ npm install mongoskin
Global installation is only to provide system-wide binaries, such as a debugger, a testing tool or the bootstrapper of Express. This means, when you install a module globally, you can call its binaries from everywhere in your system, but for an application to work you need to install it locally.
For applications, globally installed modules do not matter at all (and that's what your ls
command shows: The globally installed modules).
Hope this helps.
PS: Please note that this distinction between local and global installs is related to any module, not only to mongoskin.
PPS: You might want to check out the package.json
file, where you can put your dependencies into, so that you can automatically install them at once using a simple npm install
. To interactively create such a package.json
file, see the npm init command.
PPPS: Please also see my answer on Getting error while using Express with Node.js, it may help you to further understand what all this is about.