Received Z_BUF_ERROR while installing NativeScript


#1

I just received Z_BUF_ERROR while installing NativeScript. I did Google but without any luck.

Environment:

  • Windows 10 Enterprise 1703 64-bit
  • NodeJS v6.11.2
  • npm v5.3.0

Command:

  • npm install -g nativescript

Error Log:

  • 0 info it worked if it ends with ok
  • 1 verbose cli [ ‘C:\Program Files\nodejs\node.exe’,
  • 1 verbose cli ‘C:\Users\Hui\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js’,
  • 1 verbose cli ‘install’,
  • 1 verbose cli ‘-g’,
  • 1 verbose cli ‘nativescript’ ]
  • 2 info using npm@5.3.0
  • 3 info using node@v6.11.2
  • 4 verbose npm-session 4454628f9775be96
  • 5 silly install loadCurrentTree
  • 6 silly install readGlobalPackageData
  • 7 http fetch GET 200 https://registry.npmjs.org/nativescript 1244ms
  • 8 http fetch GET 200 https://registry.npmjs.org/nativescript/-/nativescript-3.1.3.tgz 23ms (from cache)
  • 9 silly fetchPackageMetaData error for nativescript@latest unexpected end of file
  • 10 verbose stack Error: unexpected end of file
  • 10 verbose stack at Zlib._handle.onerror (zlib.js:370:17)
  • 11 verbose cwd D:\Dev\Workspace\Local\Angular
  • 12 verbose Windows_NT 10.0.15063
    13 verbose argv “C:\Program Files\nodejs\node.exe” - “C:\Users\Hui\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js” “install” “-g” “nativescript”
  • 14 verbose node v6.11.2
  • 15 verbose npm v5.3.0
  • 16 error code Z_BUF_ERROR
  • 17 error errno -5
  • 18 error unexpected end of file
  • 19 verbose exit [ -5, true ]

Any help would be appreciated.


#2

I solved it using below commands :- --force is very important.

npm remove nativescript -g

npm cache clear --force

npm install nativescript -g