Error installing Cordova with npm in Windows 10

1

When executing in console (cmd) npm install -g cordova I get the following error:

npm ERR! Unexpected end of JSON input while parsing near '...:"^4.3.x","shelljs":"'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\usuario\AppData\Roaming\npm-cache\_logs18-06-06T01_00_41_336Z-debug.log

the log is as follows:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli   'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   'cordova',
1 verbose cli   'ionic' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session d89657513e490914
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 304 https://registry.npmjs.org/ionic 1648ms (from cache)
8 silly pacote tag manifest for [email protected] fetched in 1694ms
9 http fetch GET 304 https://registry.npmjs.org/cordova 2648ms (from cache)
10 silly pacote tag manifest for [email protected] fetched in 2773ms
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 silly install loadShrinkwrap
14 silly install loadAllDepsIntoIdealTree
15 silly resolveWithNewModule [email protected] checking installable status
16 silly resolveWithNewModule [email protected] checking installable status
17 http fetch GET 304 https://registry.npmjs.org/editor 374ms (from cache)
18 http fetch GET 304 https://registry.npmjs.org/cordova-lib 390ms (from cache)
19 silly fetchPackageMetaData error for [email protected] Unexpected end of JSON input while parsing near '...:"^4.3.x","shelljs":"'
20 silly pacote version manifest for [email protected] fetched in 406ms
21 silly resolveWithNewModule [email protected] checking installable status
22 http fetch GET 304 https://registry.npmjs.org/update-notifier 687ms (from cache)
23 silly pacote version manifest for [email protected] fetched in 718ms
24 silly resolveWithNewModule [email protected] checking installable status
25 http fetch GET 304 https://registry.npmjs.org/configstore 781ms (from cache)
26 silly pacote version manifest for [email protected] fetched in 829ms
27 silly resolveWithNewModule [email protected] checking installable status
28 http fetch GET 304 https://registry.npmjs.org/cordova-common 843ms (from cache)
29 silly pacote range manifest for [email protected]^2.2.0 fetched in 1015ms
30 silly resolveWithNewModule [email protected] checking installable status
31 http fetch GET 304 https://registry.npmjs.org/insight 1734ms (from cache)
32 silly pacote version manifest for [email protected] fetched in 1750ms
33 silly resolveWithNewModule [email protected] checking installable status
34 http fetch GET 304 https://registry.npmjs.org/nopt 1781ms (from cache)
35 silly pacote version manifest for [email protected] fetched in 1797ms
36 silly resolveWithNewModule [email protected] checking installable status
37 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...:"^4.3.x","shelljs":"'
37 verbose stack     at JSON.parse (<anonymous>)
37 verbose stack     at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-better-errors\index.js:7:17)
37 verbose stack     at consumeBody.call.then.buffer (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50)
37 verbose stack     at <anonymous>
37 verbose stack     at process._tickCallback (internal/process/next_tick.js:188:7)
38 verbose cwd C:\Users\gadgu
39 verbose Windows_NT 10.0.16299
40 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "cordova" "ionic"
41 verbose node v8.11.2
42 verbose npm  v5.6.0
43 error Unexpected end of JSON input while parsing near '...:"^4.3.x","shelljs":"'
44 verbose exit [ 1, true ]
    
asked by GADGustavo67 06.06.2018 в 03:17
source

2 answers

1

The solution part I thank TppShaka77. What I did was uninstall and install Node JS, and that's how it worked. I installed, then run in the CMD as administrator npm install , and then it worked npm install -g cordova and npm install -g ionic

    
answered by 06.06.2018 / 21:41
source
1

It has happened to me that when installing npm, sometimes the "package-lock.json" file was not configured correctly.

The file is in:

C:\Archivos de Programa\nodejs\node_modules\npm

Delete it and run the command again from the cmd (with administrator permissions) npm install.

In this way, the "package-lock.json" file will be regenerated correctly and you will be able to install the packages you need, such as Cordova.

    
answered by 06.06.2018 в 03:38