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

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

Open

Description

@joshfarrant

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).

Activity

  1. rxgx commented on Jun 21, 2017

    @rxgx

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

  2. joshfarrant commented on Jun 21, 2017

    @joshfarrant
    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.

  3. joshfarrant commented on Jun 21, 2017

    @joshfarrant
    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.

  4. prathammehta commented on Aug 3, 2017

    @prathammehta

    Also, rm package-lock.json works well.

  5. iampatilkishor commented on Aug 22, 2017

    @iampatilkishor

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

  6. raghuureddy commented on Sep 3, 2017

    @raghuureddy

    rm package-lock.json worked.

  7. willa01 commented on Oct 27, 2017

    @willa01

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

  8. LeonDWong commented on Jan 11, 2018

    @LeonDWong

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

  9. david95thinkcode commented on Jan 25, 2018

    @david95thinkcode

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

  10. added a commit that references this issue on Feb 16, 2018
  11. nishant1528 commented on Feb 22, 2018

    @nishant1528

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

  12. originalix commented on Mar 6, 2018

    @originalix

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

  13. dathobek commented on Jun 20, 2018

    @dathobek

    rm package-lock.json works well..thanks

  14. fengzifz commented on Jun 21, 2018

    @fengzifz

    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions