0

sharp@0.18.4 安装 C:\Users\hp\AppData\Roaming\npm\node_modules\sharp

node-gyp rebuild

C:\Users\hp\AppData\Roaming\npm\node_modules\sharp>if not defined npm_config_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.
MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0".
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 10.0.10240
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:\Users\hp\AppData\Roaming\npm\node_modules\sharp
gyp ERR! node -v v8.9.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN Error: EPERM: operation not permitted, rmdir 'C:\Users\hp\AppData\Roaming\npm\node_modules'
npm WARN  { Error: EPERM: operation not permitted, rmdir 'C:\Users\hp\AppData\Roaming\npm\node_modules'
npm WARN   stack: 'Error: EPERM: operation not permitted, rmdir \'C:\\Users\\hp\\AppData\\Roaming\\npm\\node_modules\'',
npm WARN   errno: -4048,
npm WARN   code: 'EPERM',
npm WARN   syscall: 'rmdir',
npm WARN   path: 'C:\\Users\\hp\\AppData\\Roaming\\npm\\node_modules' }
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\hp\AppData\Roaming\npm-cache\_logs\2017-12-27T19_25_54_261Z-debug.log
4

1 回答 1

4

在 windows 操作系统上安装sharp 的最简单方法是使用以下名为windows-build-tools的 npm 包

npm install --global --production windows-build-tools

正如 npm 所说,它会下载

安装由 Microsoft 免费提供的 Visual C++ Build Tools。这些工具是编译流行的本机模块所必需的。它还将安装 Python 2.7,适当地配置您的机器和 npm。

在这之后npm install sharp

于 2018-04-11T11:34:07.407 回答