Nodejs用'sharp'模块表示错误

时间:2017-12-13 10:16:00

标签: node.js express npm

嗨,我在下面的nodejs中遇到错误,请回复是否有人有此解决方案

Technical error has occured.
Error: Cannot find module 'sharp'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\wamp64\www\MyProject\app\helpers\ima
geUploadHelper.js:8:13)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at updateprofileImage (C:\wamp64\www\MyProject\controllers
\userController.js:421:29)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

我认为这个错误是因为模块很清晰,所以我执行'npm install sharp'来为我的项目添加清晰的模块。但后来我得到了如下错误

sharp@0.18.4 install C:\wamp64\www\MyProject\node_modules\sharp
node-gyp rebuild


C:\wamp64\www\MyProject\node_modules\sharp>if not defined npm_conf
ig_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-
bin\\..
\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild 
)
Building the projects in this solution one at a time. To enable parallel 
build,
please add the "/m" switch.
C:\wamp64\www\MyProject\node_modules\sharp\build\libvips-cpp.vcxp
roj(20,3): error MSB4019: The imported project 
"C:\Microsoft.Cpp.Default.props"
was not found. Confirm that the path in the <Import> declaration is correct, 
and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: 
`C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program 
Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:258: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 Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program 
Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" 
"rebuild"
gyp ERR! cwd C:\wamp64\www\MyProject\node_modules\sharp
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 
(node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 
fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: 
{"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.18.4 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.18.4 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!     C:\Users\roby.jacob\AppData\Roaming\npm-cache\_logs\2017-12-
13T09_59_04_884Z-debug.log

如果有人遇到相同的情况并且有解决方案,请回复。

1 个答案:

答案 0 :(得分:0)

您需要在此处更好地阅读文档:

http://sharp.dimens.io/en/stable/install/

必须在运行npm install之前安装libvips。

这将帮助您在Windows上安装libvips:

https://jcupitt.github.io/libvips/install.html

相关问题