This repository has been archived by the owner. It is now read-only.

Install error: Unexpected token < in JSON at position 35 #17340

Open
joshfarrant opened this Issue Jun 20, 2017 · 14 comments

Comments

Projects
None yet
@joshfarrant
Copy link

joshfarrant commented Jun 20, 2017

I'm opening this issue because:

  • npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don't understand.
  • Other (see below for feature requests):

What's going wrong?

Running npm i within a certain project produces the following error.

npm ERR! Unexpected token < in JSON at position 35

From the debug.log it appears that npm is trying to read the load the shrinkwrap and failing. It's worth noting that this issue only occurs in this project on my current machine. I've tested on another Fedora 22 machine, (same npm and node versions) and the install works as expected. I appreciate this points to my local environment being the cause, however it looks like there may be some invalid syntax (<) stuck in a config file somewhere that shouldn't be there and that I am unable to clear. Here is the package.json for this project.

How can the CLI team reproduce the problem?

I'm unsure how to suggest reproduction of the issue, however I'm happy to test any suggestions anyone offers and report back.

supporting information:

  • npm -v prints: 5.0.3
  • node -v prints: 8.0.0
  • npm config get registry prints: https://registry.npmjs.org/
  • Windows, OS X/macOS, or Linux?: Linux (Fedora 22)
  • Network issues:
    • Geographic location where npm was run: United Kingdom
    • I use a proxy to connect to the npm registry.
    • I use a proxy to connect to the web.
    • I use a proxy when downloading Git repos.
    • I access the npm registry via a VPN
    • I don't use a proxy, but have limited or unreliable internet access.
  • Container:
    • I develop using Vagrant on Windows.
    • I develop using Vagrant on OS X or Linux.
    • I develop / deploy using Docker.
    • I deploy to a PaaS (Triton, Heroku).
@rxgx

This comment has been minimized.

Copy link

rxgx commented Jun 21, 2017

What are you using to convert the <rootDir> in "<rootDir>/__mocks__/fileMock.js"?

@joshfarrant

This comment has been minimized.

Copy link
Author

joshfarrant commented Jun 21, 2017

That whole jest block is actually not used, I should have removed it from the included gist really.

Removing it from the project's package.json yields the same error as described above.

@joshfarrant

This comment has been minimized.

Copy link
Author

joshfarrant commented Jun 21, 2017

I've just tested with some older versions of npm (v3.7.3 and v3.10.3, using nvm to switch) and the install worked as expected. Removing the node_modules directory, switching back to npm v5.0.3, and running the install again produces the same failure listed in the original issue. It looks like this could be an issue with npm v5 after all.

@EricBeReal

This comment has been minimized.

Copy link

EricBeReal commented Aug 2, 2017

I had the same issue and a simple rm package.lock did the trick.

@prathammehta

This comment has been minimized.

Copy link

prathammehta commented Aug 3, 2017

Also, rm package-lock.json works well.

@kishorcse

This comment has been minimized.

Copy link

kishorcse commented Aug 22, 2017

delete/rename file package-lock.json will work fine

@raghuureddy

This comment has been minimized.

Copy link

raghuureddy commented Sep 3, 2017

rm package-lock.json worked.

@willa01

This comment has been minimized.

Copy link

willa01 commented Oct 27, 2017

rm package-lock.json在 npm install就好了

@LeonDWong

This comment has been minimized.

Copy link

LeonDWong commented Jan 11, 2018

This problem still remains in npm@5.6.0, could it be fixed in upcoming version?

@david95thinkcode

This comment has been minimized.

Copy link

david95thinkcode commented Jan 25, 2018

@EricBeReal thanks, that's works like a charm.

cawel pushed a commit to cawel/whatsnext.info that referenced this issue Feb 16, 2018

Martin Carel
Tries to fix the Travis build
Error message:
npm ERR! Unexpected token < in JSON at position 681

Solution (tentative):
npm/npm#17340
@nishant1528

This comment has been minimized.

Copy link

nishant1528 commented Feb 22, 2018

simple rename package.lock to any name. After building it will create new package.lock and delete previous one

@originalix

This comment has been minimized.

Copy link

originalix commented Mar 6, 2018

Thank you. rm package-lock.json works well.

@y-luis y-luis referenced this issue Jun 19, 2018

Closed

Install error #9

@dathobek

This comment has been minimized.

Copy link

dathobek commented Jun 20, 2018

rm package-lock.json works well..thanks

@fengzifz

This comment has been minimized.

Copy link

fengzifz commented Jun 21, 2018

rm package-lock.json with npm v5.6 couldn't work.
Upgrade npm to the latest version and run npm install works fine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.