为什么使用 pm2,会提示 Cannot find module 'xxx'
 发布于 12 年前  作者 zcl521ss  9048 次预览  最后一次回复是 12 年前  来自  

pm2 start index.js 查看日志有很多 Cannot find module ‘xxx’

而直接用 node index.js
就不会出错。

求解

4 回复
peiweippww

那就把这个xxx module安装上去

zcl521ss

我都安装过了 sudo npm install xxx -g

是不是他不认那个node_modules都位置?

peiweippww

@zcl521ss 应该是你安装的目录不对,你得到你那代码要调用的目录去,找到node_modules是,然后npm install xxx即可

zcl521ss

@peiweippww 哦了,可以了 只能装到应用的目录了