Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm "failed to parse json"

When I'm trying to install express with npm I always get the following error:

Failed to parse json No data, empty input at 1:1 File: /root/.npm/inherits/2.0.1/package/package.json Failed to parse package.json data. package.json must be actual JSON, not just JavaScript.  This is not a bug in npm. Tell the package author to fix their package.json file. JSON.parse 

What am I doing wrong?

 sudo npm install -g express 

OS is Ubuntu 12.04 (precise) armhf

like image 408
kovogel Avatar asked Jul 16 '15 12:07

kovogel


People also ask

What is a parse error in JSON?

parse: unexpected character" error occurs when passing a value that is not a valid JSON string to the JSON. parse method, e.g. a native JavaScript object. To solve the error, make sure to only pass valid JSON strings to the JSON.

What npm install does?

The npm install installs all modules that are listed on package. json file and their dependencies. npm update updates all packages in the node_modules directory and their dependencies.

How do I import JSON files into ES modules?

The essence of the JSON modules proposal is to allow importing JSON data inside of an ES module using a regular import statement. import jsonObject from "./file. json" assert { type: "json" }; assert { type: "json" } is an import assertion indicating the module should be parsed and imported as JSON.


1 Answers

Thanks to Jivings from this comment:

npm cache clean 

solved the problem.

like image 184
3 revs, 3 users 43% Avatar answered Sep 22 '22 07:09

3 revs, 3 users 43%