Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

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

Open
1 of 13 tasks
joshfarrant opened this issue Jun 20, 2017 · 14 comments
Open
1 of 13 tasks

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

joshfarrant opened this issue Jun 20, 2017 · 14 comments

Comments

@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
Copy link

rxgx commented Jun 21, 2017

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

@joshfarrant
Copy link
Author

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
Copy link
Author

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.

@ghost
Copy link

ghost commented Aug 2, 2017

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

@prathammehta
Copy link

Also, rm package-lock.json works well.

@iampatilkishor
Copy link

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

@raghuureddy
Copy link

rm package-lock.json worked.

@willa01
Copy link

willa01 commented Oct 27, 2017

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

@LeonDWong
Copy link

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

@david95thinkcode
Copy link

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

cawel pushed a commit to cawel/whatsnext.info that referenced this issue Feb 16, 2018
Error message:
npm ERR! Unexpected token < in JSON at position 681

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

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

@originalix
Copy link

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

@dathobek
Copy link

rm package-lock.json works well..thanks

@fengzifz
Copy link

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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests