Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.6k views
in Technique[技术] by (71.8m points)

linux下离线安装了pm2之后,执行pm2报错

使用的是离线方式的安装,pm2-4.5.1.tar.gz
安装在了root文件夹下,
然后执行了 In -s /root/pm2/bin/pm2 /usr/local/bin/pm2后,
执行pm2 -v,报了以下错误:

internal/modules/cjs/loader.js:969
throw err;
^

Error: Cannot find module 'debug'
Require stack:

  • /root/pm2/constants.js
  • /root/pm2/lib/binaries/CLI.js
  • /root/pm2/bin/pm2
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/root/pm2/constants.js:7:14)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/root/pm2/constants.js',
    '/root/pm2/lib/binaries/CLI.js',
    '/root/pm2/bin/pm2'
    ]

}

请问错误要怎么解决?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

你这里的pm2是nodejs的进程管理工具 pm2吧?! 最好带上你离线模块的下载链接。
从你报错信息来看,是模块加载不对,这可能是因为模块路径信息不对,不知道为什么你要本地离线安装?而且解压后放置的位置还是root下,只软连接了具体的一个文件过去,对于这种需要包管理的,建议链接上级目录,否则搜索模块依赖关系时不一定能够保证是正确的。

此外离线安装需要自行解决依赖问题,而npm安装会自动解决依赖问题。

估计你就是没有解决好依赖问题。

解决这样的问题,你可以找一台能联网的机器,在pm2目录下执行 npm install
这样会自动安装完整的依赖,再把pm2目录下node_modules子目录整体复制到离线机器对应位置即可。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...