Sharp: Install on Windows 7 Pro failing, please help

Created on 14 Sep 2017  ·  5Comments  ·  Source: lovell/sharp

I really want to use sharp. I've followed the instructions but I'm getting errors.

I did these, both worked, no errors:

  • npm install -g --production windows-build-tools
  • npm install -g node-gyp

Then I added an environment variable for Python:

  • Computer -> Properties -> Advanced system settings -> Environment variables -> System variable
  • PYTHON = C:\Users\stephen.last\.windows-build-tools\python27\python.exe
  • Restarted cmd

Then I ran yarn add sharp in my project, but I'm getting this:

yarn add v0.22.0
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/1] ⢀ sharp: C:nodesandboxawsnode_modulessharpbuildlibvips-cpp.vcxproj(20,3): error MSB4019: The imported project "C:Microso
[-/1] ⢀ waiting...
[-/1] ⢀ waiting...
[-/1] ⢀ waiting...
error C:nodesandboxawsnode_modulessharp: Command failed.
Exit code: 1
Command: C:windowssystem32cmd.exe
Arguments: /d /s /c node-gyp rebuild
Directory: C:nodesandboxawsnode_modulessharp
Output:
@ C:nodesandboxawsnode_modulessharp
$ if not defined npm_config_node_gyp (node "C:Program Files (x86)Yarnbinnode-gyp-bin\....node_modulesnode-gypbinnode-gyp.js" rebuild ) else (node rebuild )
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn C:Usersstephen.last.windows-build-toolspython27python.exe
gyp info spawn args [ 'C:\Program Files (x86)\Yarn\node_modules\node-gyp\gyp\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=auto',
gyp info spawn args '-I',
gyp info spawn args 'C:\node\sandbox\aws\node_modules\sharp\build\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Program Files (x86)\Yarn\node_modules\node-gyp\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\stephen.last\.node-gyp\6.10.1\include\node\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\Users\stephen.last\.node-gyp\6.10.1',
gyp info spawn args '-Dnode_gyp_dir=C:\Program Files (x86)\Yarn\node_modules\node-gyp',
gyp info spawn args '-Dnode_lib_file=node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\node\sandbox\aws\node_modules\sharp',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\node\sandbox\aws\node_modules\sharp\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn C:WindowsMicrosoft.NETFrameworkv4.0.30319msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:nodesandboxawsnode_modulessharpbuildlibvips-cpp.vcxproj(20,3): error MSB4019: The imported project "C:Microsoft.Cpp.Default.props" was not found. Confirm that the path in the 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 (x86)Yarnnode_modulesnode-gyplibbuild.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files (x86)\Yarn\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:nodesandboxawsnode_modulessharp
gyp ERR! node -v v6.10.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

How do I get this working..??

question

All 5 comments

error MSB4019: The imported project "C:Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

Hello, please see #420 #483

Right... It's taken me all day to get this working, I've done nothing else!

If there is any way, any way at all that sharp can be made to work on Windows by simply doing npm i sharp like almost everything else installed via npm/yarn, that would help so much!

I'm pretty sure that https://github.com/sass/node-sass uses C++, and that just installs, without having to go off and get lots of other things installed first.

Having no external runtime dependencies is great, but Windows users really need no external install time dependencies as well.

This is what I have installed right now, which is the only combination of software and versions that seems to work for me:

  • Windows 7 Pro
  • node 6.11.3 (6.10.1 didn't work!)
  • npm 5.2.0 (5.4.1 didn't work!)
  • Microsoft Visual C++ Build Tools (Visual C++ 2015 Build Tools)
  • Microsoft .NET Framework 4.7 (Vista / 7 only)
  • Python 2.7.13 (v3.x.x is not supported)
  • npm config set python <full-path-to-python.exe>
  • npm config set msvs_version 2015

I had to upgrade my node version, and downgrade my npm version. The downgrade has lead to other problems (with Atom and StandardJS) which I now have to sort out.

I've just tried sharp for the first time, I resized an image, it was blisteringly fast! Many thanks go to the maintainers of sharp! :+1:

Glad to hear you got it working.

Please subscribe to #186 for updates about the provision of pre-built binaries, an approach similar to that used by node-sass.

Really looking forward to #186. On top of how generally complicated it is to get the build tools working for Windows, the popularity of yarn now adds another small wrinkle because apparently yarn can't be used to install the windows-build-tools package.

At least for me, trying to run the following never works properly:
yarn global add --production windows-build-tools

So it appears that npm is still required even if one uses yarn for package management--even if it is only used to install the windows build tools via:
npm install --global --production windows-build-tools

This worked wonders for me on a Windows installation...

set GYP_MSVS_VERSION=2015
npm install --msvs_version=2015
npm install node-gyp -g
npm install sharp

Using Yarn?
I went into a different directory and just installed it there, it's all global so it works. Also did this so it wouldn't conflict with my yarn node_modules folder.

Was this page helpful?
0 / 5 - 0 ratings