用forever作为Nodejs的守护进程启动,linux有报错,求解释
用forever作为Nodejs的守护进程启动,linux有报错,求解释
error: Could not read .foreverignore file. error: ENOENT, open '/.foreverignore’ Failed to load c++ bson extension, using pure JS version js-bson: Failed to load c++ bson extension, using pure JS version
Error: Most middleware (like compress) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware. at Function.Object.defineProperty.get (/opt/node/mptool/node_modules/express/lib/express.js:89:13) at Object.<anonymous> (/opt/node/mptool/app.js:39:17) 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 Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3
error: Forever detected script exited with code: 8 error: Script restart attempt #1
/usr/lib/node_modules/forever/node_modules/forever-monitor/node_modules/watch/main.js:73 if (err) throw err; ^ Error: ENOENT, stat ‘/proc/25442/cwd/bin’
问题描述
在使用 forever
作为 Node.js 的守护进程启动时,在 Linux 系统上遇到了一些错误。错误信息包括文件读取失败、缺少 C++ 扩展以及脚本重启尝试等。
错误分析
-
.foreverignore
文件读取错误error: Could not read .foreverignore file. error: ENOENT, open '/.foreverignore'
这个错误提示
.foreverignore
文件无法被读取。可能是因为该文件不存在或者路径不正确。确保.foreverignore
文件存在并且路径正确。 -
C++ 扩展加载错误
Failed to load c++ bson extension, using pure JS version js-bson: Failed to load c++ bson extension, using pure JS version
这通常是因为缺少某些依赖项或编译环境配置不正确。确保安装了所有必要的依赖项,并且编译环境已正确配置。
-
Express 中间件错误
Most middleware (like compress) is no longer bundled with Express and must be installed separately.
这个错误提示 Express 中间件不再包含在 Express 中,需要单独安装。可以尝试运行以下命令来安装缺失的中间件:
npm install express-compress
-
Forever 脚本重启错误
error: Forever detected script exited with code: 8 error: Script restart attempt #1
这个错误提示脚本由于某种原因退出,并且
forever
尝试重新启动它。检查脚本是否有异常退出的原因。 -
文件路径错误
Error: ENOENT, stat '/proc/25442/cwd/bin'
这个错误提示找不到指定路径的文件。确保路径正确,并且文件存在。
示例代码与解决方案
-
检查
.foreverignore
文件- 确保
.foreverignore
文件存在且路径正确。 - 如果不需要
.foreverignore
文件,可以删除或注释掉相关代码。
- 确保
-
安装缺失的依赖项
- 确保安装了所有必要的依赖项:
npm install
- 确保安装了所有必要的依赖项:
-
安装缺失的中间件
- 安装缺失的中间件:
npm install express-compress
- 安装缺失的中间件:
-
检查脚本错误
- 检查脚本中是否有异常退出的原因,例如:
try { // 你的代码 } catch (err) { console.error(err); process.exit(1); // 异常退出 }
- 检查脚本中是否有异常退出的原因,例如:
通过以上步骤,应该能够解决大部分错误并成功启动 Node.js 应用程序。如果还有其他问题,请提供更多的错误日志以便进一步排查。
没有回答的吗
这个应该是程序的问题吧,和forever没有关系吧,Error: Most middleware (like compress) is no longer bundled with Express and must be installed separately
forever给node打了一个响亮的耳光