赞
踩
用nvm安装node时终端报错:
- .type aesni_cbc_sha256_enc_avx2,@function
- ^
- ../deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/aes/aesni-sha256-x86_64.s:2439:8: error: invalid alignment value
- .align 64
- ^
- ../deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/aes/aesni-sha256-x86_64.s:4080:1: error: unknown directive
- .size aesni_cbc_sha256_enc_avx2,.-aesni_cbc_sha256_enc_avx2
- ^
- ../deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/aes/aesni-sha256-x86_64.s:4081:1: error: unknown directive
- .type aesni_cbc_sha256_enc_shaext,@function
- ^
- ../deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/aes/aesni-sha256-x86_64.s:4082:8: error: invalid alignment value
- .align 32
- ^
- ../deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/aes/aesni-sha256-x86_64.s:4435:1: error: unknown directive
- .size aesni_cbc_sha256_enc_shaext,.-aesni_cbc_sha256_enc_shaext
- ^
- make[1]: *** [/Users/admin/.nvm/.cache/src/node-v10.24.1/files/out/Release/obj.target/openssl/deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/aes/aesni-sha256-x86_64.o] Error 1
- rm a151194e89fcf3752f3d05351e9f891bee165204.intermediate
- make: *** [node] Error 2
- nvm: install v10.24.1 failed!
或者安装npm包时终端报错:
<--- Last few GCs ---> [57807:0x128008000] 54 ms: Scavenge 11.1 (14.0) -> 10.5 (14.8) MB, 0.4 / 0.0 ms (average mu = 1.000, current mu = 1.000) allocation failure [57807:0x128008000] 58 ms: Scavenge 11.7 (15.0) -> 11.1 (15.8) MB, 0.3 / 0.0 ms (average mu = 1.000, current mu = 1.000) allocation failure [57807:0x128008000] 66 ms: Scavenge 13.4 (16.4) -> 12.8 (21.9) MB, 0.7 / 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: 0x102290c38 node::Abort() [/opt/homebrew/bin/node] 2: 0x102290db8 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string<std::nullptr_t>(char const*) [/opt/homebrew/bin/node] 3: 0x102396c14 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/bin/node] 4: 0x102396ba8 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/bin/node] 5: 0x1027c4fa4 v8::internal::wasm::WasmCodeAllocator::AllocateForCodeInRegion(v8::internal::wasm::NativeModule*, unsigned long, v8::base::AddressRegion) [/opt/homebrew/bin/node] 6: 0x1027c5c1c v8::internal::wasm::NativeModule::CreateEmptyJumpTableInRegion(unsigned int, v8::base::AddressRegion) [/opt/homebrew/bin/node] 7: 0x1027c51e8 v8::internal::wasm::NativeModule::AddCodeSpace(v8::base::AddressRegion) [/opt/homebrew/bin/node] 8: 0x1027c5a64 v8::internal::wasm::NativeModule::NativeModule(v8::internal::wasm::WasmEngine*, v8::internal::wasm::WasmFeatures const&, bool, 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>*) [/opt/homebrew/bin/node] 9: 0x1027c7944 v8::internal::wasm::WasmCodeManager::NewNativeModule(v8::internal::wasm::WasmEngine*, v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, bool, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/bin/node] 10: 0x1027cdc70 v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, bool, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/bin/node] 11: 0x1027cdbb8 v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/bin/node] 12: 0x1027ac3a8 v8::internal::wasm::AsyncCompileJob::CreateNativeModule(std::__1::shared_ptr<v8::internal::wasm::WasmModule const>) [/opt/homebrew/bin/node] 13: 0x1027b3860 v8::internal::wasm::AsyncCompileJob::PrepareAndStartCompile::RunInForeground(v8::internal::wasm::AsyncCompileJob*) [/opt/homebrew/bin/node] 14: 0x1027b4004 v8::internal::wasm::AsyncCompileJob::CompileStep::Run(v8::internal::wasm::AsyncCompileJob*, bool) [/opt/homebrew/bin/node] 15: 0x1027b3f14 v8::internal::wasm::AsyncCompileJob::CompileTask::RunInternal() [/opt/homebrew/bin/node] 16: 0x1022e66cc node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task> >) [/opt/homebrew/bin/node] 17: 0x1022e58f4 node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/opt/homebrew/bin/node] 18: 0x1028da454 uv__async_io [/opt/homebrew/bin/node] 19: 0x1028e9fdc uv__io_poll [/opt/homebrew/bin/node] 20: 0x1028da874 uv_run [/opt/homebrew/bin/node] 21: 0x1022c6aa0 node::NodeMainInstance::Run() [/opt/homebrew/bin/node] 22: 0x10226d8c0 node::Start(int, char**) [/opt/homebrew/bin/node] 23: 0x18a195450 start [/usr/lib/system/libdyld.dylib] [1] 57806 abort npm run dev
Node 在新款的 Mac 的 M1 macOS 系统运行的不是很好。就比如有些脚本在建立在 arm64 上的 Node 时会崩溃。
可以执行以下代码检查电脑上的 node 是不是运行在 arm64 上:
- $ node
-
- Welcome to Node.js v12.21.0.
- Type ".help" for more information.
- >
- > process.arch
- 'arm64'
目前已经修复的Node版本:v15 及以上版本。
办法1:在 Rosetta 2 模式下用 nvm 安装 node
在 nvm github 官方库里的一个 issue 里有很好的解答:
回答中写道:这种方式是只在需要的时候使用 Rosetta 模式,而不需要整个终端进入 Rosetta 模式。
什么是 Rosetta 2 模式?
简单来说,其实就是M1芯片在过渡期间苹果给出的对应 X86芯片的兼容性方案。
在终端输入 arch -x86_64 zsh 回车进入Rosetta 2模式,然后就可以用 nvm install 安装 node 了(安装之前要把之前安装在 arm64 上的 node 版本卸载了。)。
每次用 nvm 安装 node 新版本前都需要先进入 Rosetta 2 模式。
- $ nvm uninstall 14
- $ arch -x86_64 zsh
- $ nvm install 14
删除项目中原来的 node_modules,重新 npm i。
办法2: 升级node版本到已修复的版本。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。