How to fix a Node.js package error when installing NativeScript

NativeScript is a free open source offering from Telerik allowing mobile development in Javascript with 100% Access to Native Platform APIs in iOS, Android and Windows Phone. With NativeScript, the entire native platform functionality is available in the JavaScript layer. I've finally found the packaging and tooling I want to use to develop native applications in iOS and Android, while using a single language.

I develop in Windows and I love it for my daily work. However, occasionally, using Node.js on windows is a bit more complicated than on other platforms. While following the very comprehensive Getting started guide for NativeScript, I ran in to a sticky issue. Here is the issue and resolution in case it helps you, my weary web traveler friend.

Firstly, the root cause of the error was my fault. Even though the Getting Started Guide stated I needed to install "The latest Node.js 0.10.x or 0.12.x stable official release", I went off-script and installed Node 4.x. Surely this would work, right?

After spending a fair amount of time struggling with the CLI command to install NativeScript, I re-read the install docs and figured out my Node version was not the right version, so I uninstalled Node.js 4.x and installed Node 0.12.x.

After running the installer again, I still ran into issues. Part of the issue was the C++ compiler not being available. The standard way to get a C++ compiler is to install Visual Studio, though through research, I found Microsoft is offering a standalone C++ compiler specifically to help out with node. This comment by Sara Itani, discusses the new compiler, how it was tested and has the links to download what you need.

I applaud the new and improved Microsoft for their work to support the more modern development platforms like Node.

Once I had the compiler installed, I hit another error. This error was caused because the earlier version of Node.js 4.x left some paths out there that no longer resolved. Once I fixed the paths in the \nodejs\nodevars.bat, and ensured they pointed to the current install of Node 0.12.x, I was able to complete the install. Below is an example of the NativeScript install script output before the error.

view plain print about
1[C:\Users\DanWilson]npm i -g nativescript
2npm WARN excluding symbolic link docs\stylesheets\hightlight.css ->
../../node_m
3odules/highlight.js/src/styles/solarized_light.css
4npm WARN excluding symbolic link docs\assets\ir_black.css -> ../../node_modules/
5highlight.js/src/styles/ir_black.css
6npm WARN excluding symbolic link docs\stylesheets\hightlight.css -> ../../node_m
7odules/highlight.js/src/styles/solarized_light.css
8npm WARN engine xmlbuilder@2.2.1: wanted: {"node":"0.8.x || 0.10.x"} (current: {
9"node":"0.12.7","npm":"2.11.3"})
10|
11
12
13> utf-8-validate@1.0.1 install C:\Users\DanWilson\AppData\Roaming\npm\node_modul
14es\nativescript\node_modules\utf-8-validate
15> node ./build.js
16
17`win32-ia32-v8-3.28` exists; testing
18Binary is fine; exiting
19npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
20\Resources -> Versions/Current/Resources
21npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
22\Test Framework -> Versions/Current/Test Framework
23npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
24\Versions\Current -> A
25npm WARN excluding symbolic link docs\stylesheets\hightlight.css -> ../../node_m
26odules/highlight.js/src/styles/solarized_light.css
27
28
29> bufferutil@1.0.1 install C:\Users\DanWilson\AppData\Roaming\npm\node_modules\n
30ativescript\node_modules\bufferutil
31> node ./build.js
32
33`win32-ia32-v8-3.28` exists; testing
34Binary is fine; exiting
35
36> fibers@1.0.6 install C:\Users\DanWilson\AppData\Roaming\npm\node_modules\nativ
37escript\node_modules\fibers
38> node build.js || nodejs build.js
39
40`win32-ia32-v8-3.28` exists; testing
41Binary is fine; exiting
42-
43
44
45> ref@1.1.3 install C:\Users\DanWilson\AppData\Roaming\npm\node_modules\nativesc
46ript\node_modules\ref
47> node ./build.js
48
49`win32-ia32-v8-3.28` exists; testing
50Binary is fine; exiting
51npm WARN excluding symbolic link docs\assets\ir_black.css -> ../../node_modules/
52highlight.js/src/styles/ir_black.css
53npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
54\Resources -> Versions/Current/Resources
55npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
56\Test Framework -> Versions/Current/Test Framework
57npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
58\Versions\Current -> A
59npm WARN excluding symbolic link docs\stylesheets\hightlight.css -> ../../node_m
60odules/highlight.js/src/styles/solarized_light.css
61npm WARN excluding symbolic link docs\stylesheets\hightlight.css -> ../../node_m
62odules/highlight.js/src/styles/solarized_light.css
63-
64
65
66> ws@0.4.32 install C:\Users\DanWilson\AppData\Roaming\npm\node_modules\nativesc
67ript\node_modules\node-inspector\node_modules\ws
68> (node-gyp rebuild 2> builderror.log) || (exit 0)
69
70if not defined npm_config_node_gyp ( node "%~dp0\..\..\node_modules\node-gyp\bin
71\node-gyp.js" %* ) else ( node %npm_config_node_gyp% %* )
72\
73
74
75> ffi@2.0.0 install C:\Users\DanWilson\AppData\Roaming\npm\node_modules\nativesc
76ript\node_modules\ffi
77> node ./build.js
78
79`win32-ia32-v8-3.28` exists; testing
80Binary is fine; exiting
81npm ERR! Windows_NT 6.1.7601
82npm ERR! argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (
83x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "-g" "nativescript"
84npm ERR! node v0.12.7
85npm ERR! npm v2.11.3
86npm ERR! code ELIFECYCLE
87
88npm ERR! ws@0.4.32 install: `(node-gyp rebuild 2> builderror.log) || (exit 0)`
89npm ERR! Exit status 1
90npm ERR!
91npm ERR! Failed at the ws@0.4.32 install script '(node-gyp rebuild 2> builderror
92.log) || (exit 0)'.
93npm ERR! This is most likely a problem with the ws package,
94npm ERR! not with npm itself.
95npm ERR! Tell the author that this fails on your system:
96npm ERR! (node-gyp rebuild 2> builderror.log) || (exit 0)
97npm ERR! You can get their info via:
98npm ERR! npm owner ls ws
99npm ERR! There is likely additional logging output above.
100
101> nativescript@1.4.3 preuninstall C:\Users\DanWilson\AppData\Roaming\npm\node_mo
102dules\nativescript
103> node preuninstall.js
104
105Trying to kill adb server. Some running Android related operations may fail.
106
107npm ERR! Please include the following file with any support request:
108npm ERR! C:\Users\DanWilson\npm-debug.log

What I found annoying about this error, and the reason why I'm posting it here, is because the error points to a failure in the ws package.

view plain print about
1npm ERR! ws@0.4.32 install: `(node-gyp rebuild 2> builderror.log) || (exit 0)`
2npm ERR! Exit status 1
3npm ERR!
4npm ERR! Failed at the ws@0.4.32 install script '(node-gyp rebuild 2> builderror
5.log) || (exit 0)'.
6npm ERR! This is most likely a problem with the ws package,
7npm ERR! not with npm itself.
8npm ERR! Tell the author that this fails on your system:
9npm ERR! (node-gyp rebuild 2> builderror.log) || (exit 0)
10npm ERR! You can get their info via:
11npm ERR! npm owner ls ws
12npm ERR! There is likely additional logging output above.

However, I could install the WS package separately with no issue.

Good luck and happy developing with NativeScript!

There are no comments for this entry.

Add Comment Subscribe to Comments