Errors when doing npm install with Roots Sage (Wordpress theme)
I have been reading and mucking about with this for hours. I am getting the following error when trying to install Roots Sage
I am using Node.Js 4.2.1 Python 2.7.10 And have Visual Studio 2015 community edition installed.
Any advice would be greatly appreciated :)
C:\Program Files (x86)\xampp\apps\wordpress\htdocs\wp-content\themes\sage [master]> npm install
npm WARN install Couldn't install optional dependency: Unsupported
> [email protected] install C:\Program Files (x86)\xampp\apps\wordpress\htdocs\wp-content\themes\sage\node_modules\buffer
util
> node-gyp rebuild
C:\Program Files (x86)\xampp\apps\wordpress\htdocs\wp-content\themes\sage\node_modules\bufferutil>if not defined npm_con
fig_node_gyp (node "C:\Users\danielo\AppData\Roaming\npm\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:\Program Files (x86)\xampp\apps\wordpress\htdocs\wp-content\themes\sage\node_modules\bufferutil\build\bufferutil.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: `msbuild` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\danielo\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\l
ib\build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\danielo\\AppData\\Roaming\\npm\\node_modules\\npm\\no
de_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Program Files (x86)\xampp\apps\wordpress\htdocs\wp-content\themes\sage\node_modules\bufferutil
gyp ERR! node -v v4.2.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1
> [email protected] install C:\Program Files (x86)\xampp\apps\wordpress\htdocs\wp-content\themes\sage\node_modules\ut
f-8-validate
> node-gyp rebuild
C:\Program Files (x86)\xampp\apps\wordpress\htdocs\wp-content\themes\sage\node_modules\utf-8-validate>if not defined npm
_config_node_gyp (node "C:\Users\danielo\AppData\Roaming\npm\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:\Program Files (x86)\xampp\apps\wordpress\htdocs\wp-content\themes\sage\node_modules\utf-8-validate\build\validation.
vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the pat
h in the <Import> declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\danielo\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\l
ib\build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\danielo\\AppData\\Roaming\\npm\\node_modules\\npm\\no
de_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Program Files (x86)\xampp\apps\wordpress\htdocs\wp-content\themes\sage\node_modules\utf-8-validate
gyp ERR! node -v v4.2.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1
C:\Program Files (x86)\xampp\apps\wordpress\htdocs\wp-content\themes\sage [master]>
Did you run vcvarsall.bat first? It's bundled with Visual Studio and sets up the environment. There's also a menu option in VS somewhere to start a shell that runs it for you.
Hey Ben, cheers for the reply :)
I know it is going to be an issue like this, I have just Googled about and from what I found I couldn't execute any steps on how to run vcvarsall.bat for VS 15.
I also just tried to find vcvarsall.bat on my hard drive and couldn't.
Any other tips?
Did you try the menu option? I forgot what it's called but it opens a new pre-configured console window.
Yeah I read through all of the menus and nothing was jumping out at me
(unless you installed VS at some different location than the default one)
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
If the vcvarsall.bat or the VC directory does not exist at the said location, then you will probably need to reinstall VS 2015 Community Edition again, and make sure C/C++ tools get installed.
One more place to check for directory configuration is the registry:
can you check the output of reg query HKLM\Software\Microsoft\MSBuild /s ?
It should be similar to https://gist.github.com/saper/124a63c38bffb0a38d9b
Closing, I'll go ahead and assume it's working for you now.
Why is this closed? None of the above solutions are correct!
Because it was inactive for nearly four months when I closed it. Also, it's a local issue more than it is a node-gyp issue.
If it is a local issue, what is the solution? Googling has this as the top 2 links and the links below that link to this thread. I currently have had to simply start my project in a new folder and that seems to(as of now) stop the problem, but I haven't fully tested so would like to know if there is a proposed solution.
Error MSB4019 means the build environment isn't set up correctly. Step one is to run vcvarsall.bat.
If that doesn't fix it, pass --msvs_version=2015 (assuming you have VS 2015 installed) to npm or node-gyp. Auto-detection sometimes doesn't work when you have (or have had) multiple versions of VS or the Windows SDK installed.
@mmccullar this is 99% a problem with how Visual Studio is set up or used. Also nobody so far provided a response to my question. So there is nothing we can do here, sorry.
@bnoordhuis and @saper That's great to hear, but I am not using Visual studio with this project - and I haven't for previous node projects either, and never encountered the error.
If I find an answer, I will comment here to help future devs who run into the issue.
Visual Studio (or rather the compiler that is bundled with it) is used to compile add-ons, i.e., modules with a native component; bufferutil in the OP's post is one such (widely used) module.
Encountered the same error trying to install pouchdb , was able to successfully install after following a suggestion from this thread: https://github.com/nodejs/node-gyp/issues/733 from a comment by user seriema... use this command : npm config set msvs_version 2013 (with your MSVS version)
You just need to install relevant tool-set and I solved it.
Also, even though the install of node-gyp did succeed, node-gyp rebuild fails. Seems to be a common issue among windows users.
Did anyone find the solution ? I'm using win10, have a node-zstd package creating issue for node-gyp, a project which is not run in visual studio. Can't wrap my head around with any or all of the solutions since none of them work for me. It is very urgent that I solve this issue as it used to work perfectly fine on linux.
@SaketN there's seems to be a bug in node-zstd on Windows. You could try another popular ZSTD module: https://www.npmjs.com/package/node-zstandard
or the excellent (for general compression)
https://www.npmjs.com/package/lzma-native
@refack Thank you very much for confirming that, and the alternatives