gpt4 book ai didi

javascript - Node 服务器在多次工作后停止工作

转载 作者:行者123 更新时间:2023-11-29 23:00:57 26 4
gpt4 key购买 nike

我有明确的设置来为我正在处理的 React 项目做服务器端渲染,并且它似乎只是异常停止工作一段时间后按照这个进程:

1) 服务器上线,返回页面成功

2) 我稍微调整了服务器文件,然后重新启动。

3) 服务器继续工作

4)调整更多,重新启动

5) 服务器停止工作,即使恢复到步骤 1 中使用的文件也是如此

6) 在删除 node_modules 并重新加载所有依赖项之前,所有 future 的尝试都会继续显示附加错误

因此,虽然我目前有一个解决方法,但每次出现这种情况时都删除整个依赖集的效率很低,而且我担心这种行为是否会在应用程序部署时出现。这是怎么回事,我该如何预防?

我已经确保 Node 没有在后台运行的剩余幽灵进程或任何东西,并且完整的运行日志与错误消息所说的没有太大区别。不确定这里要考虑的任何其他 Angular 。

E:\JsProjects\ssrproj> npm run serve

> ssrproj@0.1.0 serve E:\JsProjects\ssrproj
> cross-env NODE_ENV=production node ./server/index.js

E:\JsProjects\ssrproj\node_modules\convert-source-map\index.js:61
return SafeBuffer.Buffer.from(json, 'utf8').toString('base64');
^

TypeError: Cannot read property 'from' of undefined
at Converter.toBase64 (E:\JsProjects\ssrproj\node_modules\convert-source-map\index.js:61:28)
at Converter.toComment (E:\JsProjects\ssrproj\node_modules\convert-source-map\index.js:65:21)
at generateCode (E:\JsProjects\ssrproj\node_modules\@babel\core\lib\transformation\file\generate.js:78:76)
at runSync (E:\JsProjects\ssrproj\node_modules\@babel\core\lib\transformation\index.js:50:51)
at transformSync (E:\JsProjects\ssrproj\node_modules\@babel\core\lib\transform.js:43:38)
at Object.transform (E:\JsProjects\ssrproj\node_modules\@babel\core\lib\transform.js:22:38)
at compile (E:\JsProjects\ssrproj\node_modules\@babel\register\lib\node.js:73:20)
at compileHook (E:\JsProjects\ssrproj\node_modules\@babel\register\lib\node.js:102:12)
at Module._compile (E:\JsProjects\ssrproj\node_modules\pirates\lib\index.js:93:29)
at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ssrproj@0.1.0 serve: `cross-env NODE_ENV=production node ./server/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ssrproj@0.1.0 serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache\_logs\2019-04-13T15_17_36_311Z-debug.log

最佳答案

看起来这个错误可能是由于 safe-buffer 中的竞争条件引起的项目,它似乎是 convert-source-map 项目的依赖项。其他人有a similar error when using safe-buffer .这是我的建议。试试:

  1. 确保您拥有 convert-source-map 和所有相关项目的最新版本
  2. 避免在生产中使用 convert-source-map。

关于javascript - Node 服务器在多次工作后停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55667073/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com