我目前正在研究一个nodejs Web应用程序我在使用云代工厂在线推送应用程序时遇到了麻烦。我对错误做了一些研究,似乎可能有一些安装包有一些冲突。
这是package.json文件。
{
"dependencies": {
"c3": "^0.4.12",
"cfenv": "1.0.0",
"cloudant": "^1.8.0",
"dygraphs": "^2.0.0",
"express": "4.5.1",
"getmac": "1.0.6",
"http": "0.0.0",
"mqtt": "1.0.5",
"properties": "1.2.1",
"save": "^2.3.0",
"sockjs": "0.3.9",
"websocket-multiplex": "0.1.x"
},
"description": "description.",
"license": "UNLICENSED",
"main": "app.js",
"repository": {
"type": "git",
"url": "<gitUrl>"
}
}
这是我尝试通过云代工推送应用程序时遇到的错误。删除node_modules文件夹的所有内容后,我在安装npm时发生类似的错误。
../src/bufferutil.cc:32:50: error: call of overloaded 'NODE_SET_METHOD(v8::Local<v8::FunctionTemplate>&, const char [6], void (&)(const v8::FunctionCallbackInfo<v8::Value>&))' is ambiguous
NODE_SET_METHOD(t, "merge", BufferUtil::Merge);
../src/bufferutil.cc:32:50: note: candidates are:
In file included from ../src/bufferutil.cc:8:0:
/root/.node-gyp/8.0.0/include/node/node.h:257:13: note: void node::NODE_SET_METHOD(v8::Local<v8::Template>, const char*, v8::FunctionCallback)
inline void NODE_SET_METHOD(v8::Local<v8::Template> recv,
^
/root/.node-gyp/8.0.0/include/node/node.h:270:13: note: void node::NODE_SET_METHOD(v8::Local<v8::Object>, const char*, v8::FunctionCallback)
inline void NODE_SET_METHOD(v8::Local<v8::Object> recv,
^
bufferutil.target.mk:95: recipe for target 'Release/obj.target/bufferutil/src/bufferutil.o' failed
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1
make: Leaving directory '/home/WibiSmart-Bluemix-App/node_modules/bufferutil/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:285:23)
gyp ERR! stack at emitTwo (events.js:125:13)
gyp ERR! stack at ChildProcess.emit (events.js:213:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Linux 4.4.30-ti-r64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/WibiSmart-Bluemix-App/node_modules/bufferutil
gyp ERR! node -v v8.0.0
gyp ERR! node-gyp -v v3.6.1
gyp ERR! not ok
有没有其他人遇到过这个问题,或者知道如何修复它?
删除package-lock.json
后重新运行npm install
找出问题所在。一些npm软件包不是最新的。我修改了package.json以安装所有软件包的所有最新版本,并修复了错误。
删除〜/ .node-gyp文件夹,然后删除〜/ .npmrc文件。
重新启动服务器并在项目文件夹中重新运行npm install
对于遇到这个确切问题的其他人:
在我的例子中,服务器节点版本在我的package.json文件中设置为比我的本地环境运行的旧版本。因此,请检查您在本地运行的内容:
node --version
-> 8.11.3
然后查看package.json中的服务器设置:
{
"name": "myapp",
"version": "0.0.0",
"private": true,
"engines": {
"node": "7.10.2" // <-- This is too old, set it to the node version you are running locally (8.11.3)
},
我希望这可以帮助别人。
这是一个古老而又一致的问题,记录在:https://github.com/nodejs/node-gyp/issues/809
对我来说错误提到了版本号:
gyp ERR! System Darwin 17.7.0
gyp ERR! node -v v12.1.0
gyp ERR! node-gyp -v v3.8.0
在尝试了所有可能的解决方案组合后(修改~/.npmrc
,删除~/.node-gyp
,清除npm缓存,删除node_modules
甚至重启系统),对我有用的是降级节点。
我相信node
和node-gyp
日志中提到的版本是不兼容的。所以我恢复了一个老式的节点版本,就像一个魅力。
npm install -g [email protected]
应该有一个明确的文档描述两者之间的重大变化和兼容性问题。
如果您使用的是NMV,您还可以更改为软件包支持的版本,例如:
nvm install 7.10.2
nvm use 7.10.2
我在安装凉亭gzweb时遇到了同样的问题。我发现apt install nodejs
在“/ usr / bin /”的方向安装“节点”。您可以通过which node
进行验证。但是node -v
仍然指的是“/ usr / local / bin / node”这是一个我无法卸载的错误版本。因此我的解决方案:
rm -rf /usr/local/bin/node
cp -i /usr/bin/node /usr/local/bin/
cp -i /usr/bin/nodejs /usr/local/bin/
脚步:
sudo apt-get install npm
npm install -g n
n stable
npm install [email protected] -g
ln -s /usr/local/bin/npm /usr/bin/npm