2

These types of questions are a dime a dozen, and I've gone through resource after resource but nothing seems to work:

Here's the deal, I'm pretty new to NodeJS and Aurelia, however my ancedotal experience is that with the advent of the recent front-end revolution and with all of its tooling, folks really made things look deceptively simple. I'm sure we've all seen commands akin to: "just run do my-work-for-me and your project is done!"

Take for instance the Aurelia guide. After navigating to the working directory, all you need to do is run:

npm install

Well, no. npm install depends on node-gyp, which you must install manually. Well, you can't install node-gyp before you install Python. But don't get the latest one, since > 3.x is not supported. Once you install that, you encounter issues with C++ compilers required by node-gyp. So we install Microsoft VS 2012 to get the compilers.

What I've done:

  1. Set PYTHON as an environment variable

     C:\Users\[name]>py
      Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
    
  2. Set the applicable VS version in npm, as proven by the getter:

     C:\Users\[name]>npm config get msvs_version
     2012
    

That said, I still encounter the following error when I attempt to run npm install from my application's target directory:

gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit c
ode: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\nod
e-gyp\lib\build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:88:13)
gyp ERR! stack     at ChildProcess.emit (events.js:173:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:201:12)
gyp ERR! System Windows_NT 6.1.7601
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:\_workspaces\skeleton-navigation-1.0.0-beta.1.0.2\node_modules\utf-8-validate
gyp ERR! node -v v5.2.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:utf-8-validate@1.2.1 utf-8-validate@1.2.1 install: `node-gyp rebuild`
npm WARN install:utf-8-validate@1.2.1 Exit status 1
Community
  • 1
  • 1
lux
  • 8,315
  • 7
  • 36
  • 49
  • Sorry, this might be a bit offtopic, but on Windows you're likely to suffer much pain like that. You might want to use, let's say, Vagrant or Docker to virtualize this. – Alexander Mikhalchenko Dec 15 '15 at 21:54
  • Not a bad suggestion actually. I was quite amazed at the ridiculousness of all this TBH. So are you saying create a VM for my local dev environment? What about the build server, same there? Maybe we'll get lucky and get a Linux build box, but I doubt it. – lux Dec 15 '15 at 21:59
  • I worked on a web client for the desktop app in a company that principally used Windows. I'm not a windows fan at all, and I struggled a lot with node-gyp for babel. So, I ended up with a Vagrant box on Ubuntu on which one can build the app (since it's just frontend, you'll only need the resulting js file). – Alexander Mikhalchenko Dec 15 '15 at 22:07
  • 1
    I'm sure that it's possible to get it up and running, but I don't think it's worth all the time you spend on that. Maybe those guys have found a better workaround for that, but I quit that job, so I don't know :) – Alexander Mikhalchenko Dec 15 '15 at 22:08
  • @AlexanderM You should have seen the look on my colleagues faces when I told them I was dling VS just to get the C++ compilers for node ;) – lux Dec 15 '15 at 22:10
  • Well, I don't understand. I use Windows, and I'm using Aurelia right now. The only thing a had to do was install Node.js and NPM. – Fabio Dec 15 '15 at 22:13
  • @FabioLuz I'm following this as gospel: http://aurelia.io/docs.html#/aurelia/framework/1.0.0-beta.1.0.3/doc/article/a-production-setup and failing on the npm install command. You were able to run through this successfully? – lux Dec 15 '15 at 22:16
  • Step 2 under "Setting up the Project Structure and Build" – lux Dec 15 '15 at 22:17
  • @lux uninstall NodeJs. Download it again from the original web site (to make sure you are using the latest version). After that, you just have to follow the tutorial – Fabio Dec 15 '15 at 22:18
  • 1
    If you decide to move to Vagrant, I've created a small git repo based on the scripts I used ;) https://github.com/strrife/nodejs-vagrant-env – Alexander Mikhalchenko Dec 15 '15 at 22:27

3 Answers3

2

I really, truly don't like answering my own questions, but I was able to resolve this by taking the following steps:

  1. Uninstall Node.js
  2. Uninstall Microsoft Visual Studio 2012
  3. Uninstall any remaining C++ 2010 x86/x64 redistributables
  4. Reinstall Node.js
  5. Use Node.js to reinstall npm
  6. Install Microsoft Studio 2013 (Express Desktop)

At this point, I should have been able to run npm install against the Aurelia directory, however I was still failing due to the error noted in the description of the issue.

  1. Explicitly tell npm to use Microsoft Studio 2013, by issuing the command:

    npm config set msvs_version 2013 --global
    
  2. Now, subsequent to this command, I was able to successfully execute npm install without any GYP errors.

I don't know why, but for whatever reason node-gyp doesn't seem to play nice with 2012, so if you're hitting this issue, I'd opt for 2013, which is actually referenced here: https://github.com/nodejs/node-gyp

lux
  • 8,315
  • 7
  • 36
  • 49
1

I'm on windows and relatively new to the node-style front-end tooling. I feel your pain.

The node gyp ERR! messages are safe to ignore. If you look closely they're always followed by npm WARN optional dep failed, continuing [some dependency]

Here's an example of one of the many gyp ERR! blocks you'll have the pleasure of seeing when npm installing using windows:

C:\repos\skeleton-navigation\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node
_modules\ws\node_modules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp
 else (node  rebuild ) s\node-gyp\bin\node-gyp.js" rebuild -)
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:114:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:69:11
gyp ERR! stack     at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\repos\skeleton-navigation\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.i
o-client\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing utf-8-validate@1.2.1
Jeremy Danyow
  • 26,470
  • 12
  • 87
  • 133
  • Interesting, this failure to find python looks catastrophic, but it's ignorable? I was able to quell this message by setting a PYTHON environment variable. That said, I was able to fully resolve this by installing VS 2013 and uninstalling all previous C++ compilers provided by VS 2012. – lux Dec 16 '15 at 17:00
0

If you have Visual Studio 2015 Community with C++ section checked, or Visual Studio 2015 Express for Desktop it will put in the right bits.

If you need minimal install for VM or just not using those tools on Windows 10 x64:

1 - Python

Install latest Python 2.7.x, not 3.x. You don't have to select option to add to PATH unless you need Python for some other tool.

2 - Microsoft Visual C++ Build Tools 2015 Technical Preview

Don't do default install, you need to select both Win8.1 and Win 10 SDKs. This is referencing download posted 11/20/2015.

Microsoft Visual C++ Build Tools 2015 Technical Preview

3 - nodejs

Tested with stable branch 5.3.0, add following globals for node-gyp.

npm --global config set msvs_version 2015

npm --global config set python c:\dev\Python27\python.exe

(or wherever you installed python, only needed if you didn't add to PATH via installer)

That's it.

git clone https ://github.com/aurelia/skeleton-navigation

cd skeleton-navigation

npm install