Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected end of JSON input while parsing near '... ^5.0.0"},"dist":{"in' #1198

Closed
theBstar opened this issue Apr 23, 2020 · 16 comments
Closed
Labels
Release 6.x work is associated with a specific npm 6 release

Comments

@theBstar
Copy link

theBstar commented Apr 23, 2020

What / Why

While running npm i next. It throws me an Unexpected end of JSON input while parsing near '... ^5.0.0"},"dist":{"in' error.

When

  • When i run npm i next
  • April 23rd 2020 @ 7:47pm IST

Where

O.S.: Ubuntu 19.10 64 bit
npm version 6.14.4
node version 12.16.2
Hardware:

  • Memory: 7.6 GiB
  • Processor: Intel® Core™ i7-9750H CPU @ 2.60GHz × 12
  • Graphics card: GeForce GTX 1650 with Max-Q Design/PCIe/SSE2

How

run npm i next

Current Behavior

It throws the error Unexpected end of JSON input while parsing near '... ^5.0.0"},"dist":{"in'
cat /home/<user>/.npm/_logs/2020-04-23T14_13_31_944Z-debug.log shows

0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'i', 'next' ] 2 info using [email protected] 3 info using [email protected] 4 verbose npm-session dabf7815c26582a5 5 silly install loadCurrentTree 6 silly install readLocalPackageData 7 http fetch GET 304 https://registry.npmjs.org/next 1625ms (from cache) 8 silly pacote tag manifest for next@latest fetched in 1650ms 9 timing stage:loadCurrentTree Completed in 1664ms 10 silly install loadIdealTree 11 silly install cloneCurrentTreeToIdealTree 12 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms 13 silly install loadShrinkwrap 14 timing stage:loadIdealTree:loadShrinkwrap Completed in 1ms 15 silly install loadAllDepsIntoIdealTree 16 silly resolveWithNewModule [email protected] checking installable status 17 http fetch GET 304 https://registry.npmjs.org/@ampproject%2ftoolbox-optimizer 409ms (from cache) 18 silly pacote version manifest for @ampproject/[email protected] fetched in 410ms 19 silly resolveWithNewModule @ampproject/[email protected] checking installable status 20 http fetch GET 304 https://registry.npmjs.org/@babel%2fplugin-proposal-optional-chaining 991ms (from cache) 21 silly pacote version manifest for @babel/[email protected] fetched in 993ms 22 silly resolveWithNewModule @babel/[email protected] checking installable status 23 http fetch GET 304 https://registry.npmjs.org/@babel%2fcore 1003ms (from cache) 24 silly pacote version manifest for @babel/[email protected] fetched in 1005ms 25 silly resolveWithNewModule @babel/[email protected] checking installable status 26 http fetch GET 304 https://registry.npmjs.org/@babel%2fplugin-proposal-object-rest-spread 1009ms (from cache) 27 silly pacote version manifest for @babel/[email protected] fetched in 1010ms 28 silly resolveWithNewModule @babel/[email protected] checking installable status 29 http fetch GET 304 https://registry.npmjs.org/@babel%2fplugin-syntax-bigint 1033ms (from cache) 30 http fetch GET 304 https://registry.npmjs.org/@babel%2fplugin-syntax-dynamic-import 1033ms (from cache) 31 http fetch GET 304 https://registry.npmjs.org/@babel%2fplugin-proposal-nullish-coalescing-operator 1040ms (from cache) 32 http fetch GET 304 https://registry.npmjs.org/@babel%2fplugin-transform-modules-commonjs 1034ms (from cache) 33 silly pacote version manifest for @babel/[email protected] fetched in 1037ms 34 silly resolveWithNewModule @babel/[email protected] checking installable status 35 silly pacote version manifest for @babel/[email protected] fetched in 1037ms 36 silly resolveWithNewModule @babel/[email protected] checking installable status 37 silly pacote version manifest for @babel/[email protected] fetched in 1038ms 38 silly resolveWithNewModule @babel/[email protected] checking installable status 39 silly pacote version manifest for @babel/[email protected] fetched in 1045ms 40 silly resolveWithNewModule @babel/[email protected] checking installable status 41 http fetch GET 304 https://registry.npmjs.org/@babel%2fplugin-proposal-numeric-separator 1049ms (from cache) 42 silly pacote version manifest for @babel/[email protected] fetched in 1050ms 43 silly resolveWithNewModule @babel/[email protected] checking installable status 44 http fetch GET 304 https://registry.npmjs.org/@babel%2fpreset-modules 317ms (from cache) 45 silly pacote version manifest for @babel/[email protected] fetched in 319ms 46 silly resolveWithNewModule @babel/[email protected] checking installable status 47 http fetch GET 304 https://registry.npmjs.org/@babel%2fpreset-env 328ms (from cache) 48 http fetch GET 304 https://registry.npmjs.org/@babel%2fpreset-react 315ms (from cache) 49 silly pacote version manifest for @babel/[email protected] fetched in 335ms 50 silly resolveWithNewModule @babel/[email protected] checking installable status 51 silly pacote version manifest for @babel/[email protected] fetched in 321ms 52 silly resolveWithNewModule @babel/[email protected] checking installable status 53 http fetch GET 304 https://registry.npmjs.org/@babel%2fpreset-typescript 307ms (from cache) 54 http fetch GET 304 https://registry.npmjs.org/@babel%2fruntime 306ms (from cache) 55 http fetch GET 304 https://registry.npmjs.org/babel-plugin-transform-define 298ms (from cache) 56 silly pacote version manifest for @babel/[email protected] fetched in 309ms 57 silly resolveWithNewModule @babel/[email protected] checking installable status 58 silly pacote version manifest for @babel/[email protected] fetched in 308ms 59 silly resolveWithNewModule @babel/[email protected] checking installable status 60 silly pacote version manifest for [email protected] fetched in 300ms 61 silly resolveWithNewModule [email protected] checking installable status 62 http fetch GET 304 https://registry.npmjs.org/@babel%2fplugin-transform-runtime 1162ms (from cache) 63 silly pacote version manifest for @babel/[email protected] fetched in 1166ms 64 silly resolveWithNewModule @babel/[email protected] checking installable status 65 http fetch GET 304 https://registry.npmjs.org/find-cache-dir 323ms (from cache) 66 http fetch GET 304 https://registry.npmjs.org/babel-plugin-transform-react-remove-prop-types 347ms (from cache) 67 http fetch GET 304 https://registry.npmjs.org/browserslist 341ms (from cache) 68 silly pacote version manifest for [email protected] fetched in 327ms 69 silly resolveWithNewModule [email protected] checking installable status 70 http fetch GET 304 https://registry.npmjs.org/css-loader 342ms (from cache) 71 silly fetchPackageMetaData error for [email protected] Unexpected end of JSON input while parsing near '... ^5.0.0"},"dist":{"in' 72 silly pacote version manifest for [email protected] fetched in 353ms 73 silly resolveWithNewModule [email protected] checking installable status 74 http fetch GET 304 https://registry.npmjs.org/fork-ts-checker-webpack-plugin 330ms (from cache) 75 silly pacote version manifest for [email protected] fetched in 350ms 76 silly resolveWithNewModule [email protected] checking installable status 77 http fetch GET 304 https://registry.npmjs.org/jest-worker 333ms (from cache) 78 silly pacote version manifest for [email protected] fetched in 339ms 79 silly resolveWithNewModule [email protected] checking installable status 80 silly pacote version manifest for [email protected] fetched in 339ms 81 silly resolveWithNewModule [email protected] checking installable status 82 http fetch GET 304 https://registry.npmjs.org/loader-utils 328ms (from cache) 83 silly pacote version manifest for [email protected] fetched in 332ms 84 silly resolveWithNewModule [email protected] checking installable status 85 http fetch GET 304 https://registry.npmjs.org/mini-css-extract-plugin 325ms (from cache) 86 silly fetchPackageMetaData error for [email protected] Unexpected end of JSON input while parsing near '...tandard-version":"^4.' 87 http fetch GET 304 https://registry.npmjs.org/@babel%2fplugin-proposal-class-properties 2007ms (from cache) 88 silly pacote version manifest for @babel/[email protected] fetched in 2011ms 89 silly resolveWithNewModule @babel/[email protected] checking installable status 90 http fetch GET 304 https://registry.npmjs.org/native-url 330ms (from cache) 91 http fetch GET 304 https://registry.npmjs.org/mkdirp 331ms (from cache) 92 silly pacote version manifest for [email protected] fetched in 334ms 93 warn deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.) 94 silly resolveWithNewModule [email protected] checking installable status 95 silly pacote version manifest for [email protected] fetched in 336ms 96 silly resolveWithNewModule [email protected] checking installable status 97 http fetch GET 304 https://registry.npmjs.org/pnp-webpack-plugin 339ms (from cache) 98 http fetch GET 304 https://registry.npmjs.org/postcss 336ms (from cache) 99 silly pacote version manifest for [email protected] fetched in 344ms 100 silly resolveWithNewModule [email protected] checking installable status 101 http fetch GET 304 https://registry.npmjs.org/prop-types 337ms (from cache) 102 silly pacote version manifest for [email protected] fetched in 340ms 103 silly resolveWithNewModule [email protected] checking installable status 104 silly pacote version manifest for [email protected] fetched in 339ms 105 silly resolveWithNewModule [email protected] checking installable status 106 http fetch GET 304 https://registry.npmjs.org/prop-types-exact 310ms (from cache) 107 silly pacote version manifest for [email protected] fetched in 314ms 108 silly resolveWithNewModule [email protected] checking installable status 109 http fetch GET 304 https://registry.npmjs.org/babel-plugin-syntax-jsx 1229ms (from cache) 110 silly pacote version manifest for [email protected] fetched in 1232ms 111 silly resolveWithNewModule [email protected] checking installable status 112 http fetch GET 304 https://registry.npmjs.org/@babel%2ftypes 1268ms (from cache) 113 http fetch GET 304 https://registry.npmjs.org/react-is 308ms (from cache)

Steps to Reproduce

run npm i next

Expected Behavior

next installs successfully.

@ljharb
Copy link
Contributor

ljharb commented Apr 23, 2020

Is your package.json valid?

@theBstar
Copy link
Author

theBstar commented Apr 23, 2020

@ljharb .Yes it is. Here is my package.json generated with npm init -y
{ "name": "rock", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" }

@HolySpirit777
Copy link

I am having the same issue when I try to create a new angular project using ng new, the console throws the error: Unexpected end of JSON input while parsing near ''

@bilel-tlili
Copy link

Im' facing the same problem, when i try to install any package it throws the error Unxpected end of JSON ....

@rajkumarGosavi
Copy link

Me too. I tried changing the registry and cleaning cache but none of it works

@bilel-tlili
Copy link

it was a network issue and now it's resolved by just connecting on another network

@theBstar
Copy link
Author

theBstar commented Jun 7, 2020

Still facing the issue, where yarn just works fine.
Unexpected end of JSON input while parsing near '...\nwsFcBAEBCAAQBQJdik/' while installing yarn and babel

@jdmarshall
Copy link

jdmarshall commented Jul 21, 2020

I am setting up a proxy server trying to fix this issue for some of my coworkers with crap bandwidth while stuck at home. None of the commentary I can find anywhere has anything other than the workaround, which is to run:

npm run cache clean -f

which I highly suspect may be no more effective than "wait couple of minutes and try again"

@jdmarshall
Copy link

I notice that pacote has been substantially re-implemented, but hasn't been picked up yet by npm.
I'm curious if that would fix this problem.

@darcyclarke darcyclarke added the Release 6.x work is associated with a specific npm 6 release label Oct 30, 2020
@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

@jdmarshall
Copy link

npm 7 only ships with node 16 right?

That's a lot of people out in the cold for a very, very long time.

@ljharb
Copy link
Contributor

ljharb commented Jun 5, 2021

@jdmarshall it also ships with node 15. But anyone with node 10+ can npm install -g npm

@jdmarshall
Copy link

I have to get every single one of my coworkers and the ops team to upgrade npm on every machine where our code runs, builds, or is developed. What 'anyone' can do is practically irrelevant in this kind of conversation. See also "you can use GC in C"... only if all of my coworkers and every library we use also agree to do it.

@jdmarshall
Copy link

jdmarshall commented Jan 28, 2022

This feels like a problem where npm neglecting to honor an error callback, and is also not checking Content-Length against bytes received. Either of these checks should result in the item being dropped. The fact that we are caching bad entries suggests that neither is happening.

For a large project, and a team all working remotely (aren't we all these days?) npm cache clear --force is an expensive ask, and objectively, if we got a premature EOF the last time we ran, there's a good chance it will happen again if I have to fetch every single module into an empty cache. Running the gauntlet again may (and empirically, often does) result in worse behavior than the original run.

Written from my desk, where I am running an npm build over and over again because 1) no cache and 2) a different module errors out every time, even after substantially pruning our node_modules directory

@ljharb
Copy link
Contributor

ljharb commented Jan 28, 2022

@jdmarshall typically the node and npm version for developers are controlled by devops/infra, precisely so that this kind of change is easy.

I agree clearing the cache isn't something that's ideal, and I'm not saying that's something that's easy to do.

All my comment is saying is that you can try the newest npm (7 on node 10, 8 on node 12+), and if it's still a problem, then please do file an issue, as #1198 (comment) indicates.

@jdmarshall
Copy link

jdmarshall commented Jan 28, 2022

Well now I get SHA errors or occasionally connection reset depending on where it happens.
So new behavior, but still the same results, if a little less frequently (which could just be network fluctuations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release 6.x work is associated with a specific npm 6 release
Projects
None yet
Development

No branches or pull requests

7 participants