Npm ERR! Unexpected end of JSON input while parsing near '...rg/@firebase/app/-/ap'

Hello, following the installation guide, at the point:
npm init npx openzeppelin init
I get the message:
npm ERR! 404 Not Found - GET https://registry.npmjs.org/openzeppelin - Not found
Reviewing in the forum I find that the solution to this problem is solved with:
$ npm i @openzeppelin/cli
However, when running this command I get this error:
npm WARN deprecated truffle-config@1.1.16: WARNING: This package has been renamed to @truffle/config.
npm WARN deprecated typechain-target-truffle@1.0.2: For TypeChain 2.x use @typechain/truffle-v4 or v5
npm WARN deprecated typechain-target-web3-v1@1.0.4: For TypeChain 2.x use @typechain/web3-v1
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm ERR! Unexpected end of JSON input while parsing near ‘…rg/@firebase/app/-/ap’
My versions are:
Truffle v5.1.21 (core: 5.1.21)
Node v12.16.1
How can i solve this problem?

1 Like

Hi @gabo,

Welcome to the community :wave:

I am sorry that you are having this error.

As per the npm documentation: https://docs.npmjs.com/common-errors#invalid-json You could try npm cache clean

I wasn’t able to reproduce on WSL2 with:

$ npx truffle version
Truffle v5.1.40 (core: 5.1.40)
Solidity v0.5.16 (solc-js)
Node v12.16.1
Web3.js v1.2.1

Which installation guide did you have the following without npm i @openzeppelin/cli inbetween? I want to get the guide updated:

npm init
npx openzeppelin init
1 Like

Thank you very much for your answer, it effectively solved the problem with npm cache clean --force
About the guide I relied on that does not contain the npm i @openzeppelin/cli statement is the following:
https://docs.openzeppelin.com/learn/setting-up-a-node-project

1 Like

Hi @gabo,

Glad to hear that you are up and running.

Thanks for the feedback on the documentation. The example was showing the difference between installing/running packages globally vs locally (using npx), though I could see how this could be confusing.

$ openzeppelin init
openzeppelin: command not found
$ npx openzeppelin init
Welcome to the OpenZeppelin SDK!

Updating the Learn guides is on my to do list, so I will see how I can improve this example when I do that.

1 Like