[eggjs/egg]按照官网创建项目后npm run xxx无法正常启动

2024-06-28 793 views
8
[egg-scripts] Start got error, see /Users/xxxx/logs/master-stderr.log
[egg-scripts] Or use `--ignore-stderr` to ignore stderr at startup.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project-serve@1.0.0 start: `egg-scripts start --daemon --title=egg-server-project-serve`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the project-serve@1.0.0 start 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!     /Users/xxxx/.npm/_logs/2021-06-01T08_17_10_492Z-debug.log

本地环境: Mac M1 Node版本 12+、14+ (nvm管理) 安装官网安装项目模板,结果提示上述信息,无法启动项目

尝试修复: 方案一: package.json下的script脚本追加 --ignore-stderr 忽略日志,结果不行 方案二:Google出来大部分方案是: 切换node、npm版本、换yarn、 清楚npm缓存,重装node_modles包,都尝试过的,还是无法启动项目

回答

0

这不是应该先看提示里的日志文件错误信息是啥?

8

<--- Last few GCs --->

[5362:0x158008000]       42 ms: Scavenge 6.0 (9.0) -> 4.9 (9.5) MB, 0.3 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 
[5362:0x158008000]       50 ms: Scavenge 6.7 (13.5) -> 5.4 (14.8) MB, 0.3 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 
[5362:0x158008000]       78 ms: Scavenge 9.9 (15.3) -> 7.3 (15.6) MB, 0.4 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure 

<--- JS stacktrace --->

FATAL ERROR: wasm code commit Allocation failed - process out of memory
 1: 0x100dfb740 node::Abort() [/Users/eastbaot/.nvm/versions/node/v14.16.1/bin/node]
 2: 0x100dfb8c0 node::errors::TryCatchScope::~TryCatchScope() [/Users/eastbaot/.nvm/versions/node/v14.16.1/bin/node]
 3: 0x100f14960 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/eastbaot/.nvm/versions/node/v14.16.1/bin/node]
 4: 0x100f148f4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/eastbaot/.nvm/versions/node/v14.16.1/bin/node]
 5: 0x1014a9720 v8::internal::wasm::WasmCodeAllocator::AllocateForCodeInRegion(v8::internal::wasm::NativeModule*, unsigned long, v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/eastbaot/.nvm/versions/node/v14.16.1/bin/node]
 6: 0x1014aa3ac v8::internal::wasm::NativeModule::CreateEmptyJumpTableInRegion(int, v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/eastbaot/.nvm/versions/node/v14.16.1/bin/node]
 7: 0x1014a907c v8::internal::wasm::NativeModule::AddCodeSpace(v8::base::AddressRegion, v8::internal::wasm::WasmCodeAllocator::OptionalLock const&) [/Users/eastbaot/.nvm/versions/node/v14.16.1/bin/node]
 8: 0x1014aa1bc v8::internal::wasm::NativeModule::NativeModule(v8::internal::wasm::WasmEngine*, v8::internal::wasm::WasmFeatures const&, v8::internal::VirtualMemory, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>, std::__1::shared_ptr<v8::internal::Counters>, std::__1::shared_ptr<v8::internal::wasm::NativeModule>*) [/Users/eastbaot/.nvm/versions/node/v14.16.1/bin/node]
8

请教下这是什么问题

6

启动的时候就 OOM 了,堆内存溢出导致进程 crash

8

估计你加载的哪个插件或者中间件有问题

8

尴尬的是我刚按照官网创建的新项目模板,还没开始写代码呢,啥都没操作,就报这个问题 (?)

4

这就很奇怪了- -,不过我没有 M1 的环境,要不然可以帮你试下看看

9

嗯嗯,谢谢,我再去google下

4

我在 m1 上跑 node14 没有发现 OOM,有几点可以确认下。

arm 包应该只有 16 才支持,14 的话确认下这个 node 版本是否是本地编译的,如果直接下载的 node 可能存在兼容性问题。

1

嗯嗯,感谢,发现日志里面的确输出了wasm code commit Allocation failed - process out of memory, 分配失败-进程内存不足,我本地nvm node12~14版本都试过,都不行,发现这个问题在node 15+已被修复。

提示:如果你使用基于 arm64架构macOS下的 node@12,它可能会在一些脚本上崩溃

目前我已安装node@15+,此问题已解决!!! @popomore @hyj1991

9

不要用单数的 Node 版本,是不稳定版本来着