I\'m trying to install the filepreview
module with npm
. But it always gives error. Here is the error:
D:\\Program Files\\nodejs\\P
I have come across this same issue in the past. Here is the solution. You may need to restart your machine several times to clear all the errors.
Solution:
1. Install Install VC++ Build Tools 2017 and while installing select V140 from the side menu
2. Install Python 2.7, and add it to your PATH
3. npm config set python python2.7 --global
4. npm config set python C:\Python27\python.exe --global
5. npm config set msvs_version 2015 --global
6. set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140
**Note: If you still face error > most likely the problem is node-sass is not installed**
After this step you have to restart your machine
7. Install the latest versions of Python
8. As Admin:
$ cd "C:\Program Files\nodejs\node_modules\npm"
$ npm install node-gyp
9. $ npm config set msvs_version 2015 --global
Note: that I have VS 2017, but configuring it as ver 2017 won't work. Not sure why.
10. As Admin:
$ npm install -g node-sass
And finally, one last check:
$ node-sass -v
Hope it helps.
I turned off the automatic update from visual studio of npm's packages
After spending more than 3 days finally found the solution at https://spin.atomicobject.com/2019/03/27/node-gyp-windows/
It worked when I ran "npm install -no-optional" The -no-optional flag ensures that npm installs only the required packages.
A quick note : I followed all the steps listed in https://github.com/nodejs/node-gyp#on-windows and finally ran "npm install -no-optional"
I did the same. I'm still getting errors. Is there anyone who can help
gyp verb node dev dir C:\Users\_UserName_\.node-gyp\12.10.0
gyp verb found first Solution file build/binding.sln
gyp verb using MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args 'build/binding.sln',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 9/19/2019 3:43:05 PM.
Project "C:\_ProjectPath_\node_modules\node-sass\build\binding.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Release|x64".
Project "C:\_ProjectPath_\node_modules\node-sass\build\binding.sln" (1) is building "C:\_ProjectPath_\node_modules\node-sass\build\binding.vcxproj.metaproj" (2) on node 1 (default targets).
Project "C:\_ProjectPath_\node_modules\node-sass\build\binding.vcxproj.metaproj" (2) is building "C:\_ProjectPath_\node_modules\node-sass\build\src\libsass.vcxproj" (3) on node 1 (default targets).
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\_ProjectPath_\node_modules\node-sass\build\src\libsass.vcxproj]
Done Building Project "C:\_ProjectPath_\node_modules\node-sass\build\src\libsass.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\_ProjectPath_\node_modules\node-sass\build\binding.vcxproj.metaproj" (default targets) -- FAILED.
Done Building Project "C:\_ProjectPath_\node_modules\node-sass\build\binding.sln" (default targets) -- FAILED.
Build FAILED.
"C:\_ProjectPath_\node_modules\node-sass\build\binding.sln" (default target) (1) ->
"C:\_ProjectPath_\node_modules\node-sass\build\binding.vcxproj.metaproj" (default target) (2) ->
"C:\_ProjectPath_\node_modules\node-sass\build\src\libsass.vcxproj" (default target) (3) ->
(PlatformPrepareForBuild target) ->
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\_ProjectPath_\node_modules\node-sass\build\src\libsass.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.37
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\_ProjectPath_\node_modules\node-sass\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:209:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\_ProjectPath_\\node-sass\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\_ProjectPath_\node_modules\node-sass
gyp ERR! node -v v12.10.0
gyp ERR! node-gyp -v v3.8.0
Simple fix worked for me is:
I installed Python 3.7 and installed Visual Studio version 2017 from https://my.visualstudio.com/Downloads?q=visual%20studio%202017
Also installed recommended updates.
And then I set npm config set msvs_version 2017 --global.
It's node version problem. I'm currently on the latest feature version (Current Version). The newer node is not supported yet. To solve the problem, you could switch to LTS version which is normally fully supported.
Easy switch would be (If you are using brew):
brew unlink node
and then link the node lts verion (right now is node@12) as the following:
brew install node@12 && brew link --overwrite node@12 --force
That solved for me.