4
votes

I was trying to install sharp module, which requires: c++ compiler - I downloaded Visual Studio 2017 and visual c++ build tools node-gyp - It was installed successfully

But running 'npm install -g sharp' I got many errors

  • gyp ERR! stack Error: E:\VS\MSBuild\15.0\Bin\MSBuild.exe failed with exit code: 1
  • gyp ERR! stack at ChildProcess.onExit (C:\Users\MyUsername\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\li \build.js:258: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:200:12)
  • gyp ERR! System Windows_NT 10.0.15063
  • gyp ERR! command "C:\Program Files\nodejs\node.exe"
  • "C:\Users\MyUsername\AppData\Roaming\npm\node_modules\npm\nod _modules\node-gyp\bin\node-gyp.js" "rebuild"
  • gyp ERR! cwd C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp
  • gyp ERR! node -v v8.5.0
  • gyp ERR! node-gyp -v v3.6.2
  • gyp ERR! not ok
  • npm WARN Error: EPERM: operation not permitted, unlink
  • 'C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp\node_modu es\color-name\package.json'
  • npm WARN { Error: EPERM: operation not permitted, unlink 'C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp\node_m dules\color-name\package.json'
  • npm WARN stack: 'Error: EPERM: operation not permitted, unlink \'C:\Users\MyUsername\AppData\Roaming\npm\node_module \sharp\node_modules\color-name\package.json\'',
  • npm WARN errno: -4048,
  • npm WARN code: 'EPERM',
  • npm WARN syscall: 'unlink',
  • npm WARN path:
  • 'C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp\node_modules\color-name\package.json' }
  • npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] install: node-gyp rebuild npm ERR! Exit status 1

If it matters - I'm a Windows user

2
Have you installed nodejs?forJ
Yes, I have it installedNurislam Fazulzyanov

2 Answers

3
votes

It sounds like build tools are not installed, You have to install the build tools for Windows

npm install --global windows-build-tools

more details

0
votes

Just came across a similar problem and after a lot of searches online, it seems like a problem with the latest node version that automatically integrate and use v8 engine, that older dependencies doesn't support. it seems like an ms-build problem, but that's probably not the real issue. I have tried the following without success:

  1. Downgre node version to 10.8.0 and then installing
  2. Remove %APPDATA%\npm-cache\_libvips and installing from here
  3. Run npm install --global windows-build-tool

This is how I solved it:

  1. Uninstall nodejs and npm (and make sure the folder C:/Program Files/nodejs was deleted and also if any npm install location is still remaining, delete it. An example is C:\Users<username>\AppData\Roaming\npm)
  2. Install Node version 14.16.0 (I recommend using nvm for this task)
  3. Update npm to its latest version by running npm install npm@latest -g
  4. Navigate to your project's folder (where the installation previously failed) and run npm install --ignore-scripts
  5. (On a side note), if that's being used with node-sass you'd might want to also run this: npm rebuild node-sass --force --ignore-scripts