npm install multer错误
发布于 3 个月前 作者 lgk007 404 次浏览 来自 问答

npm install multer报错,不明原因? 1.png

[email protected] install /Users/liuguangkuo/Documents/www/sportq-platform-tools/webapps/tools/node_modules/magickwand node-gyp rebuild

CXX(target) Release/obj.target/magickwand/src/module.o …/src/module.cpp:4:16: error: use of undeclared identifier 'NanNew’ exports->Set(NanNew<String>(“resize”), ^ …/src/module.cpp:4:23: error: ‘String’ does not refer to a value exports->Set(NanNew<String>(“resize”), ^ /Users/liuguangkuo/.node-gyp/5.9.0/include/node/v8.h:2078:17: note: declared here class V8_EXPORT String : public Name { ^ …/src/module.cpp:5:7: error: use of undeclared identifier 'NanNew’ NanNew<FunctionTemplate>(resizeAsync)->GetFunction()); ^ …/src/module.cpp:5:14: error: ‘FunctionTemplate’ does not refer to a value NanNew<FunctionTemplate>(resizeAsync)->GetFunction()); ^ /Users/liuguangkuo/.node-gyp/5.9.0/include/node/v8.h:4345:17: note: declared here class V8_EXPORT FunctionTemplate : public Template { ^ …/src/module.cpp:5:44: error: member reference base type ‘Nan::NAN_METHOD_RETURN_TYPE (Nan::NAN_METHOD_ARGS_TYPE)’ (aka ‘void (const FunctionCallbackInfov8::Value &)’) is not a structure or union NanNew<FunctionTemplate>(resizeAsync)->GetFunction()); ~~~~~~~~~~~~~^ ~~~~~~~~~~~ …/src/module.cpp:7:16: error: use of undeclared identifier 'NanNew’ exports->Set(NanNew<String>(“thumbnail”), ^ …/src/module.cpp:7:23: error: ‘String’ does not refer to a value exports->Set(NanNew<String>(“thumbnail”), ^ /Users/liuguangkuo/.node-gyp/5.9.0/include/node/v8.h:2078:17: note: declared here class V8_EXPORT String : public Name { ^ …/src/module.cpp:8:7: error: use of undeclared identifier 'NanNew’ NanNew<FunctionTemplate>(thumbnailAsync)->GetFunction()); ^ …/src/module.cpp:8:14: error: ‘FunctionTemplate’ does not refer to a value NanNew<FunctionTemplate>(thumbnailAsync)->GetFunction()); ^ /Users/liuguangkuo/.node-gyp/5.9.0/include/node/v8.h:4345:17: note: declared here class V8_EXPORT FunctionTemplate : public Template { ^ …/src/module.cpp:8:47: error: member reference base type ‘Nan::NAN_METHOD_RETURN_TYPE (Nan::NAN_METHOD_ARGS_TYPE)’ (aka ‘void (const FunctionCallbackInfov8::Value &)’) is not a structure or union NanNew<FunctionTemplate>(thumbnailAsync)->GetFunction()); ~~~~~~~~~~~~~~~~^ ~~~~~~~~~~~ 10 errors generated. make: *** [Release/obj.target/magickwand/src/module.o] Error 1 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:276:23) gyp ERR! stack at emitTwo (events.js:100:13) gyp ERR! stack at ChildProcess.emit (events.js:185:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12) gyp ERR! System Darwin 15.2.0 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 /Users/liuguangkuo/Documents/www/sportq-platform-tools/webapps/tools/node_modules/magickwand gyp ERR! node -v v5.9.0 gyp ERR! node-gyp -v v3.2.1 gyp ERR! not ok npm WARN install:[email protected] [email protected] install: node-gyp rebuild npm WARN install:[email protected] Exit status 1 npm WARN saveError Unexpected token } /Users/liuguangkuo/Documents/www/sportq-platform-tools/webapps/tools └── [email protected]

npm WARN Failed to parse json npm WARN Trailing comma in object at 20:3 npm WARN } npm WARN ^ npm WARN File: /Users/liuguangkuo/Documents/www/sportq-platform-tools/webapps/tools/package.json npm WARN tools No description npm WARN tools No repository field. npm WARN tools No README data npm WARN tools No license field.

7 回复

错误信息说多了逗号,发一下这个文件? /Users/liuguangkuo/Documents/www/sportq-platform-tools/webapps/tools/package.json

你是先写 package.json 再安装还是 npm 指定要安装的包? 把 “serve-favicon”: “~2.3.0” 后面的逗号去掉试试吧

@IchiNiNiIchi { “name”: “tools”, “version”: “0.0.0”, “private”: true, “scripts”: { “start”: “node ./bin/www” }, “dependencies”: { “body-parser”: “~1.15.1”, “cookie-parser”: “~1.4.3”, “debug”: “~2.2.0”, “ejs”: “~2.4.1”, “express”: “~4.13.4”, “express-formidable”: “^0.1.3”, “md5-node”: “^1.0.1”, “morgan”: “~1.7.0”, “multer”: “^1.2.0”, “node-fetch”: “^1.6.0”, “request”: “^2.74.0”, “serve-favicon”: “~2.3.0”, } }

@IchiNiNiIchi 我是npm install --save multer安装的,刚刚uninstall multer,然后删除serve-favicon后面的逗号,然后重新install,还是一样。

@lgk007 奇怪,你 package.json 都没指定 magickwand,而且 multer 都不依赖 magickwand,怎么这里会去安装它呢?

magickwand的问题…… 看它的package.jsonnan*,然而现在npm install安装的nan是v2.4.0了 magickwand用的NanNew()是nan v1.x的语法了,v2.x改成Nan::New()了 so

yarn 在向你招手

回到顶部