爆款云服务器低至4折,1核1G¥366/

出现错误原因

运行 npm install 时出现以下错误

> sleep@5.2.3 install /root/nideshop/node_modules/sleep
> node-gyp rebuild

make: Entering directory `/root/nideshop/node_modules/sleep/build'
  CXX(target) Release/obj.target/node_sleep/sleep.o
make: g++: Command not found
make: *** [Release/obj.target/node_sleep/sleep.o] Error 127
make: Leaving directory `/root/nideshop/node_modules/sleep/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/root/.nvm/versions/node/v8.14.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 3.10.0-862.14.4.el7.x86_64
gyp ERR! command "/root/.nvm/versions/node/v8.14.0/bin/node" "/root/.nvm/versions/node/v8.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/nideshop/node_modules/sleep
gyp ERR! node -v v8.14.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN nideshop@1.0.0 No description
npm WARN nideshop@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sleep@5.2.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sleep@5.2.3 install 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!     /root/.npm/_logs/2018-12-13T11_35_02_817Z-debug.log

解决方法

yum install -y make gcc-c++

重新执行 npm install

标签: Node.js, CentOS