1

Al ejecutar en consola (cmd) npm install -g cordova me aparece el siguiente 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\_logs\2018-06-06T01_00_41_336Z-debug.log

el log es el siguiente:

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 ionic@latest fetched in 1694ms
9 http fetch GET 304 https://registry.npmjs.org/cordova 2648ms (from cache)
10 silly pacote tag manifest for cordova@latest 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 cordova-common@^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 ]
2
  • ¿Has ejecutado el cmd con permisos de administrador?
    – fredyfx
    el 6 jun. 2018 a las 1:22
  • Lo que hice es buscar el "Símbolo del Sistema" y ejecutarlo como Administrador, pero si hay otra forma correcta me lo puedes decir... el 6 jun. 2018 a las 14:33

2 respuestas 2

1

Me ha pasado que al instalar npm en ocasiones el archivo "package-lock.json" no se configuro correctamente.

El archivo se encuentra en:

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

Elimínalo y vuelve a correr el comando desde el cmd (con permisos de administrador) npm install.

De ese modo se regenerará el archivo "package-lock.json" de forma correcta y podrás instalar los package que necesites, como el Cordova.

5
  • Hola, en esa ubicación no tengo "package-lock.json", pero tengo "package.json", y el inicio del archivo es el siguiente: { "version": "5.6.0", "name": "npm", "description": "a package manager for JavaScript", "keywords": [ "install", "modules", "package manager", "package.json" ], "preferGlobal": true, "config": { "publishtest": false }, "homepage": "docs.npmjs.com", "author": "Isaac Z. Schlueter <[email protected]> (blog.izs.me)", "repository": { "type": "git", "url": "github.com/npm/npm" } el 6 jun. 2018 a las 14:38
  • Te recomiendo entonces borrar toda la carpeta de node_modules y vuelve a correr el comando de npm install De ahi vuelve a instalar Cordova. Todo esto desde la línea de cmd con permisos de adminsitrador.
    – TppShaka77
    el 6 jun. 2018 a las 14:59
  • Lo hice y me tiro el error: Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js' el 6 jun. 2018 a las 19:29
  • Eso te lo marca cuando intentas volver a correr el comando npm install npm@latest ?
    – TppShaka77
    el 6 jun. 2018 a las 19:40
  • ejecute ´npm install´, sin npm@latest el 6 jun. 2018 a las 19:43
1

la solución parte le agradezco a TppShaka77. Lo que hice fue desinstalar e instalar Node JS, y así funcionó. Instalé, luego ejecute en el CMD como administrador npm install, y luego funcionó npm install -g cordova y npm install -g ionic

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.