The npm system is encountering difficulties in parsing the package.json file

Having recently started using npm and node, I decided to create a react app with truffle unbox react using npm init react-app. Despite attempting to reinstall npm and clear the cache multiple times, I consistently encounter an error when trying to run sudo npm start.

npm ERR! code EJSONPARSE
npm ERR! file /home/a/Documents/so/client/package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token { in JSON at position 634 while parsing near '...rsion"
npm ERR! JSON.parse     ]
npm ERR! JSON.parse   }
npm ERR! JSON.parse }
npm ERR! JSON.parse 
npm ERR! JSON.parse {
npm ERR! JSON.parse "name": "mapboxAnd...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/a/.npm/_logs/2020-06-21T17_39_45_819Z-debug.log

The contents of my package.json are as follows:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "16.11.0",
    "react-dom": "16.11.0",
    "react-scripts": "3.2.0",
    "web3": "1.2.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

I have confirmed that the package.json file strictly adheres to the JSON format. Any insights on resolving this issue would be greatly appreciated. Thank you!

Answer №1

It appears that your package.json file is properly formatted as valid JSON, so the error may be located elsewhere in your system. Below are some steps you can take to troubleshoot:

  1. Try running the package without using sudo, for example use "npm start" instead of "sudo npm start". Running packages as root should be avoided.
  2. Check the log file at "/home/a/.npm/_logs/2020-06-21T17_39_45_819Z-debug.log" for more information and provide additional details from it.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What are the potential consequences of using outdated npm dependencies?

I encountered an error while trying to run my Gatsby project that was built last November both locally and on Netlify. The error message I received is as follows: Error: [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/node_modules/dot-prop/in ...

Why does the Angular page not load on the first visit, but loads successfully on subsequent visits and opens without any issues?

I am currently in the process of converting a template to Angular that utilizes HTML, CSS, Bootstrap, JavaScript, and other similar technologies. Within the template, there is a loader function with a GIF animation embedded within it. Interestingly, upon ...

Utilize the ng-controller directive with unique aliases across various sections of HTML code

I'm facing an issue with my ng-controllers when multiple controllers are used on the same page. For instance, I have one controller in the page header, another in a different section of the same page, and one in the content of the page. However, all o ...

Utilizing a function within a span element

Can anyone help me figure out what I'm doing wrong while trying to toggle between a span and an input text field using the on function? If you want to take a look, I've created a fiddle for it here User Interface <div> <span >My va ...

Ways to thwart CSRF attacks?

I am currently looking for ways to protect my API from CSRF attacks in my Express app using Node.js. Despite searching on both Google and YouTube, I have been unable to find a solution that works for me. One tutorial I watched on YouTube recommended gene ...

Ways to implement the don't repeat yourself (DRY) principle in React JS with condition-based logic

https://i.stack.imgur.com/xkrEV.gif Here is a sample way to use the component: import React from "react"; import MyAvatars from "../../components/MyAvatar/MyAvatars"; const About = () => { return ( <MyAvatars ...

Issue occurs when a circle element is not following a div element on mouse

Currently, I have implemented some jQuery code that instructs a div named small-circle to track my cursor movement. I discovered how to accomplish this by referencing a thread on stack overflow. I made slight modifications to the script to suit my specifi ...

What is the process for implementing a custom error when compiling Sass code with node-sass?

When using node-sass to compile my sass code, I am curious about the possibilities during the compilation process. To clarify, I am interested in creating custom rules and generating specific errors under certain conditions while compiling. ...

Passing arguments from an Angular directive to a controller function within an element's HTML

Is there a way to pass the URL of an anchor tag in the directive to the controller function "itemClicked"? The code below successfully logs the "post" object when clicked. HTML: <div ng-repeat="post in posts" > <div find-urls link-clicked="i ...

Can I import an npm package into Nexus 2 by curling it?

I have attempted to use the following command: curl -v <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cdaba4a1a8f08dbfaca3a9a2a0e0a3b8a0afa8bfe0aaa8a3a8bfacb9a2bfe0fce3fde3fde3b9aab7">[email protected]</a> -u adm ...

Populating a Listview in jqueryMobile with dynamic elements

I am struggling with my listview. Whenever I try to add or remove items from the list, the jquery mobile styling does not get applied to the new content that is added. <ul data-role="listview" id="contributionList"> <li id="l1"><a>5. ...

What is the best way to handle KML/GeoJSON data in Node.js?

I've come to a point where I've exhausted all my Google searches and now asking for help here. Currently, we are processing a KML file using geoXml3 on the client side. However, ideally, I would like to preprocess it on the server side and then s ...

Tips for customizing the cursor to avoid it reverting to the conventional scroll cursor when using the middle click

When you wish to navigate by scrolling with the middle mouse button instead of using the scroll wheel, simply middle-click and your cursor will change allowing for easy scrolling on web pages. Even though I am utilizing style="cursor: pointer" and @click. ...

What are some effective ways to integrate the WordPress API with ReactJS?

Wordpress recently introduced an API that allows you to make HTTP requests without worrying about routes, as the backend is handled for you. I'm curious, how can I integrate ReactJs with Wordpress API? This has been a frustrating challenge for me be ...

Utilizing React Typescript for Passing Props and Implementing them in Child Components

I'm currently working with React and TypeScript and attempting to pass data as props to a child component for use. However, I've encountered an error that I can't quite understand why it's happening or how to resolve it. Additionally, I ...

Issue with jQuery's $(this).serialize() function not functioning correctly

&cellphone=0400000000¬es=this+is+a+test The mistake is visible above You'll notice that the following error has occurred ¬es It was actually supposed to be &notes= I'm curious why this happened. Below is the HTML form: <!---lef ...

Troubleshooting: The issue of importing Angular 2 service in @NgModule

In my Angular 2 application, I have created an ExchangeService class that is decorated with @Injectable. This service is included in the main module of my application: @NgModule({ imports: [ BrowserModule, HttpModule, FormsModu ...

Encountering issues with NPM functionality while configuring NODE/NPM as a non-admin user

I came across this helpful guide at and decided to give Node.js a try on my work computer. Despite following all the instructions, I was able to get Node showing its version but couldn't find NPM. The current path is C:\TOOLS\nodejs Runn ...

Verify whether a specific value is present within a nested array in MongoDB

Looking to verify whether a value sent in a request already exists within an array associated with a particular User. The data structure is as follows: { "_id": "63233972df0f14076e027106", "firstName": "mako" ...