Visit Sponsor

Written by 9:26 am Mobile Development, NativeScript

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.


[C:\Users\DanWilson]npm i -g nativescript
npm WARN excluding symbolic link docs\stylesheets\hightlight.css -> ../../node_m
odules/highlight.js/src/styles/solarized_light.css
npm WARN excluding symbolic link docs\assets\ir_black.css -> ../../node_modules/
highlight.js/src/styles/ir_black.css
npm WARN excluding symbolic link docs\stylesheets\hightlight.css -> ../../node_m
odules/highlight.js/src/styles/solarized_light.css
npm WARN engine xmlbuilder@2.2.1: wanted: {"node":"0.8.x || 0.10.x"} (current: {
"node":"0.12.7","npm":"2.11.3"})
|

> utf-8-validate@1.0.1 install C:\Users\DanWilson\AppData\Roaming\npm\node_modul
es\nativescript\node_modules\utf-8-validate
> node ./build.js

`win32-ia32-v8-3.28` exists; testing
Binary is fine; exiting
npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
\Resources -> Versions/Current/Resources
npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
\Test Framework -> Versions/Current/Test Framework
npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
\Versions\Current -> A
npm WARN excluding symbolic link docs\stylesheets\hightlight.css -> ../../node_m
odules/highlight.js/src/styles/solarized_light.css

> bufferutil@1.0.1 install C:\Users\DanWilson\AppData\Roaming\npm\node_modules\n
ativescript\node_modules\bufferutil
> node ./build.js

`win32-ia32-v8-3.28` exists; testing
Binary is fine; exiting

> fibers@1.0.6 install C:\Users\DanWilson\AppData\Roaming\npm\node_modules\nativ
escript\node_modules\fibers
> node build.js || nodejs build.js

`win32-ia32-v8-3.28` exists; testing
Binary is fine; exiting
-

> ref@1.1.3 install C:\Users\DanWilson\AppData\Roaming\npm\node_modules\nativesc
ript\node_modules\ref
> node ./build.js

`win32-ia32-v8-3.28` exists; testing
Binary is fine; exiting
npm WARN excluding symbolic link docs\assets\ir_black.css -> ../../node_modules/
highlight.js/src/styles/ir_black.css
npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
\Resources -> Versions/Current/Resources
npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
\Test Framework -> Versions/Current/Test Framework
npm WARN excluding symbolic link examples\TestFramework\Test Framework.framework
\Versions\Current -> A
npm WARN excluding symbolic link docs\stylesheets\hightlight.css -> ../../node_m
odules/highlight.js/src/styles/solarized_light.css
npm WARN excluding symbolic link docs\stylesheets\hightlight.css -> ../../node_m
odules/highlight.js/src/styles/solarized_light.css
-

> ws@0.4.32 install C:\Users\DanWilson\AppData\Roaming\npm\node_modules\nativesc
ript\node_modules\node-inspector\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

if not defined npm_config_node_gyp ( node "%~dp0\..\..\node_modules\node-gyp\bin
\node-gyp.js" %* ) else ( node %npm_config_node_gyp% %* )
\

> ffi@2.0.0 install C:\Users\DanWilson\AppData\Roaming\npm\node_modules\nativesc
ript\node_modules\ffi
> node ./build.js

`win32-ia32-v8-3.28` exists; testing
Binary is fine; exiting
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (
x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "-g" "nativescript"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE

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

> nativescript@1.4.3 preuninstall C:\Users\DanWilson\AppData\Roaming\npm\node_mo
dules\nativescript
> node preuninstall.js

Trying to kill adb server. Some running Android related operations may fail.

npm ERR! Please include the following file with any support request:
npm 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.


npm ERR! ws@0.4.32 install: `(node-gyp rebuild 2> builderror.log) || (exit 0)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ws@0.4.32 install script '(node-gyp rebuild 2> builderror
.log) || (exit 0)'.
npm ERR! This is most likely a problem with the ws package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! (node-gyp rebuild 2> builderror.log) || (exit 0)
npm ERR! You can get their info via:
npm ERR! npm owner ls ws
npm 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!

Visited 10,459 times, 1 visit(s) today
[mc4wp_form id="5878"]
Close