I am having a bit of an issue getting the md5
node module installed properly on an Ubuntu dev server I have setup.
(It works fine on my local windows machine, and I can install other modules with npm just fine on the dev server)
When I try and start a NodeJS application I am working on it fails stating that the md5
module is not installed.
// trying to start my application that depends on md5.
drichardson@devwebserver:/var/www/node_app/meanapp$ node server.js
module.js:340
throw err;
^
Error: Cannot find module 'md5'
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.<anonymous> (/var/www/node_app/node_modules/hashfile/index.js:7:11)
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)
at require (module.js:380:17)
at Object.<anonymous> (/var/www/node_app/meanapp/app/controllers/exchanges.server.controller.js:15:14)
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)
I have tried installing this within my working directory:
// Installing in working directory
drichardson@devwebserver:/var/www/node_app/meanapp$ sudo npm install --save md5
npm http GET https://registry.npmjs.org/md5
npm http GET https://registry.npmjs.org/md5
npm http 304 https://registry.npmjs.org/md5
npm http GET https://registry.npmjs.org/is-buffer
npm http GET https://registry.npmjs.org/crypt
npm http GET https://registry.npmjs.org/charenc
npm http 304 https://registry.npmjs.org/crypt
npm http GET https://registry.npmjs.org/is-buffer
npm http GET https://registry.npmjs.org/charenc
npm http 200 https://registry.npmjs.org/is-buffer
npm http GET https://registry.npmjs.org/is-buffer/-/is-buffer-1.0.2.tgz
npm http GET https://registry.npmjs.org/is-buffer/-/is-buffer-1.0.2.tgz
npm http GET https://registry.npmjs.org/charenc
npm http GET https://registry.npmjs.org/charenc/-/charenc-0.0.1.tgz
npm http 200 https://registry.npmjs.org/charenc/-/charenc-0.0.1.tgz
npm http GET https://registry.npmjs.org/is-buffer/-/is-buffer-1.0.2.tgz
npm http 200 https://registry.npmjs.org/is-buffer/-/is-buffer-1.0.2.tgz
[email protected] node_modules/md5
├── [email protected]
├── [email protected]
└── [email protected]
Even though the node module shows up in my /node_modules folder, it still throws the "Cannot find module md5
"
// MD5 In my node_modules folder:
drichardson@devwebserver:/var/www/node_app/meanapp/node_modules$ ls -la | grep 'md5'
drwxr-xr-x 2 drichardson drichardson 4096 Oct 30 13:53 md5
I have also tried:
- Installing the module globally with "npm install -g md5"
- Cleaning the Cache and Reinstalling "npm cache clean"
- Reinstalling the application with "npm install"
What else can I try to get this so that npm recognizes md5 as being installed?
Thanks,
To fix the Cannot find module error, simply install the missing modules using npm . This will install the project's dependencies into your project so that you can use them. Sometimes, this might still not resolve it for you. In this case, you'll want to just delete your node_modules folder and lock file ( package-lock.
Global libraries On Unix systems they are normally placed in /usr/local/lib/node or /usr/local/lib/node_modules when installed globally. If you set the NODE_PATH environment variable to this path, the modules can be found by node.
How does npm install packages globally? Global modules are installed in the /usr/local/lib/node_modules project directory in the standard system, which is the system's root. Print the location of all global modules on your system using this command.
I had a similar issue and the problem wasn't where the module was installed, but instead it was because the main
property in the package.json
file was not correctly set. In my case it referred to a file that wasn't there. Make sure that the "main":"..."
is set correctly for the module.
If this is a module that you do not control, as a quick fix you can make the change in the nearest node_modules directory. In our case this was located in the root of the project.
Can you try clearing entire node_modules and installing everything again?
rm -rf node_modules
npm install
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