I implemented a npm module (called wrench) in an application which I always tested locally. That worked always without problems. Then I was trying to install wrench on my server.
npm install wrench
did work as expected but as soon as it comes to require("wrench")
, I get the following error:
> require("wrench")
Error: Cannot find module 'wrench'
at Function._resolveFilename (module.js:320:11)
at Function._load (module.js:266:25)
at require (module.js:348:19)
at [object Context]:1:1
at Interface.<anonymous> (repl.js:171:22)
at Interface.emit (events.js:64:17)
at Interface._onLine (readline.js:153:10)
at Interface._line (readline.js:408:8)
at Interface._ttyWrite (readline.js:585:14)
at ReadStream.<anonymous> (readline.js:73:12)
If I run npm ls
I can see
[email protected]
Is there something I am missing here?
Thanks,
Elias
If there is a package. json already existing in your project folder, then from command line you need to go to your project folder and type npm start. npm install --save grunt // And you need to do for all the node_modules, by replacing the **grunt**. Automatically the dependency will be added to your package.
Use the npm list to show the installed packages in the current project as a dependency tree. Use npm list --depth=n to show the dependency tree with a specified depth. Use npm list --prod to show packages in the dependencies . Use npm list --dev to show packages in the devDependencies .
I believe npm ls
shows all the the packages available on npm. To see the installed packages I think you should issue npm ls installed
.
I have:
alfred@alfred-laptop:~$ node -v
v0.4.1
alfred@alfred-laptop:~$ npm --version
0.2.17
I issue:
alfred@alfred-laptop:~$ npm install wrench
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info fetch http://registry.npmjs.org/wrench/-/wrench-0.1.0.tgz
npm info calculating sha1 /home/alfred/local/lib/node/.npm/nvm/0.0.6/package/v0.4.1/lib/node/.npm/.cache/wrench/0.1.0/package.tgz
npm info shasum 07440ad670068e0e81c8126c4641d1ca73b83557
npm info preinstall [email protected]
npm info install [email protected]
npm info postinstall [email protected]
npm info preactivate [email protected]
npm info activate [email protected]
npm info postactivate [email protected]
npm info build Success: [email protected]
npm ok
alfred@alfred-laptop:~$ node
> require('wrench')
{ rmdirSyncRecursive: [Function],
copyDirSyncRecursive: [Function],
chmodSyncRecursive: [Function] }
>
My advice is to use the latest and greatest npm and node.js and try again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With