Dav*_*ich 4 md5 node.js npm npm-install
我在将md5节点模块正确安装到已设置的Ubuntu开发服务器上时遇到了一个问题。
(它在我的本地Windows机器上可以正常工作,我可以在开发服务器上使用npm安装其他模块)
当我尝试启动NodeJS应用程序时,我在处理该应用程序失败,说明md5未安装该模块。
// 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)
Run Code Online (Sandbox Code Playgroud)
我尝试将其安装在我的工作目录中:
// 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
md5@2.0.0 node_modules/md5
??? charenc@0.0.1
??? crypt@0.0.1
??? is-buffer@1.0.2
Run Code Online (Sandbox Code Playgroud)
即使节点模块显示在我的/ node_modules文件夹中,它仍会引发“找不到模块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
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
-使用“ npm install -g md5”全局安装模块
-清洁缓存并重新安装“ npm cache clean”
-使用“ npm install”重新安装应用程序
我还能尝试什么以使npm识别md5已安装?
谢谢,
我有一个类似的问题,问题不在模块的安装位置,而是因为文件中的main属性package.json未正确设置。在我的情况下,它引用的文件不存在。确保"main":"..."为模块正确设置。
如果这是您无法控制的模块,则可以快速在最近的node_modules目录中进行更改,作为快速解决方案。在我们的案例中,它位于项目的根目录中。
您可以尝试清除整个node_modules并重新安装所有内容吗?
rm -rf node_modules
npm install
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3949 次 |
| 最近记录: |