问题:当我用linux,使用npm install -g truffle命令安装truffle的时候,报错。
- 注意:一定要把解压的node-v16.9.1-linux-x64放到/usr/local下,不要放在自己的根目录下。
问题1:
遇到Error: EACCES: permission denied, access '/usr/local/node-v16.9.1-linux-x64/lib/node_modules'
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/node-v16.9.1-linux-x64/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/node-v16.9.1-linux-x64/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/node-v16.9.1-linux-x64/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/node-v16.9.1-linux-x64/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/zzh/.npm/_logs/2021-09-24T06_34_04_617Z-debug.log
解决:用sudo npm来启动,如果无法启动,执行ln -s /usr/local/node-v16.9.1-linux-x64/bin/node /usr/bin/node,ln -s /usr/local/node-v16.9.1-linux-x64/bin/npm /usr/bin/npm
===================================
出现以下问题,都是我把node-v16.9.1-linux-x64放到/root目录才出现的。
问题2:
ENOTEMPTY: directory not empty, rename '/root/node-v16.9.1-linux-x64/lib/node_modules/truffle' -> '/root/node-v16.9.1-linux-x64/lib/node_modules/.truffle-Ze0QcZFw'
[root@iZj6celeu0hb204t50d9cwZ ethereum]# npm install -g truffle
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /root/node-v16.9.1-linux-x64/lib/node_modules/truffle
npm ERR! dest /root/node-v16.9.1-linux-x64/lib/node_modules/.truffle-Ze0QcZFw
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/root/node-v16.9.1-linux-x64/lib/node_modules/truffle' -> '/root/node-v16.9.1-linux-x64/lib/node_modules/.truffle-Ze0QcZFw'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-09-24T06_09_41_037Z-debug.log
解决:不要去重命名这个文件 '/root/node-v16.9.1-linux-x64/lib/node_modules/truffle' -> '/root/node-v16.9.1-linux-x64/lib/node_modules/.truffle-Ze0QcZFw'。尝试删除package-lock.json文件和node_module包,然后重新npm install。
===================================
问题3:FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
[root@iZj6celeu0hb204t50d9cwZ ethereum]# npm install -g truffle
⸨#########⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠇ idealTree: timing idealTree Completed in 10754ms
<--- Last few GCs --->
[1658:0x64249a0] 141939 ms: Scavenge 1999.1 (2086.1) -> 1995.1 (2086.1) MB, 8.2 / 0.1 ms (average mu = 0.435, current mu = 0.342) allocation failure
[1658:0x64249a0] 141974 ms: Scavenge 2000.2 (2086.1) -> 1996.9 (2086.1) MB, 7.4 / 0.0 ms (average mu = 0.435, current mu = 0.342) allocation failure
[1658:0x64249a0] 142014 ms: Scavenge 2002.6 (2086.1) -> 1998.9 (2102.1) MB, 12.8 / 0.1 ms (average mu = 0.435, current mu = 0.342) allocation failure
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 0xafcff0 node::Abort() [npm install truffle]
2: 0xa14113 node::FatalError(char const, char const) [npm install truffle]
3: 0xce5c7e v8::Utils::ReportOOMFailure(v8::internal::Isolate, char const, bool) [npm install truffle]
4: 0xce5ff7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, bool) [npm install truffle]
5: 0xeb4495 [npm install truffle]
6: 0xec3c11 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [npm install truffle]
7: 0xec67be v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [npm install truffle]
8: 0xe881ea v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [npm installtruffle]
9: 0x11fd286 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long, v8::internal::Isolate) [npm install truffle]
10: 0x15e67d9 [npm install truffle]
解决:export NODE_OPTIONS=--max_old_space_size=5120
===================================
问题4:sh: node-gyp-build: command not found
npm WARN deprecated ethereumjs-testrpc@6.0.3: ethereumjs-testrpc has been renamed to ganache-cli, please use this package from now on.
npm ERR! code 127
npm ERR! path /root/node-v16.9.1-linux-x64/lib/node_modules/truffle/node_modules/bufferutil
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! sh: node-gyp-build: command not found
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-09-24T06_35_03_505Z-debug.log
解决:npm install node-gyp-build -g
网友评论