question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Receiving [Browserslist] Could not parse <ProjectDirectory>/ClientApp/package.json when using ASP.NET+React.js template

See original GitHub issue

This issue has been moved from a ticket on Developer Community.


[severity:I’m unable to use this version] I have tried creating a sample project using the ASP.NET+React.js template in Visual Studio 2019 for Mac but keep encountering the following error when trying to launch the app:

AggregateException: One or more errors occurred. (One or more errors occurred. (The npm script 'start' exited without indicating that the create-react-app server was listening for requests. The error output was: [Browserslist] Could not parse <ProjectDirectory>/ClientApp/package.json. Ignoring it. ))

System.Threading.Tasks.Task<TResult>. GetResultCore(bool waitCompletionNotification)
System.Threading.Tasks.Task<TResult>.get_Result()
Microsoft.AspNetCore.SpaServices.Extensions.Util.TaskTimeoutExtensions.WithTimeout<T>(Task<T> task, TimeSpan timeoutDelay, string message)
Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.PerformProxyRequest(HttpContext context, HttpClient httpClient, Task<Uri> baseUriTask, CancellationToken applicationStoppingToken, bool proxy404s)
Microsoft.AspNetCore.Builder.SpaProxyingExtensions+<>c__DisplayClass2_0+<<UseProxyToSpaDevelopmentServer>b__0>d.MoveNext()
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

This occurs in both .NET Core 3.1 and .NET 5.0, Node and NPM version output is as follows:

node --version
v17.0.1

npm ---version
8.1.0

Given the exception, I tried changing the following in package.json from this:

"browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
}

To this:

"browserslist": [
      ">0.2%",
      "not dead",
      "not op_mini all"
]

However, this had no impact. Additionally, I tried executing the following command from the ClientApp directory:

npx browserslist --update-db

This still did not resolve the issue. I have a clean install of Node and this issue happens regardless of .NET versions. If anyone could help with this, it would be greatly appreciated.

Thanks


Original Comments

Feedback Bot on 11/7/2021, 11:17 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Feedback Bot on 11/16/2021, 02:12 AM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.


Original Solutions

(no solutions)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
BrassHeadcommented, Jan 28, 2022

The package.json file from the template was saved in “utf8 with BOM”. The BOM causes parsing to fail. Removing the BOM (by creating a new file and copy paste the contents as suggested by @q-omar or using some other tool) will fix the problem.

2reactions
q-omarcommented, Jan 26, 2022

I copied the contents of package.json, deleted it, created a new file and pasted the contents. App began working then. I think there was some invisible character that was throwing off the parser 🤷‍♂️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not parse the JSON file ,Error in Progam.cs asp.net ...
FormatException: 'Could not parse the JSON file. Error on line number '0': ''.' How to resolve it?
Read more >
ASP.NET Core: System.FormatException: Could not parse ...
FormatException: Could not parse the JSON file.' error for a ASP.NET Core site hosted in Azure, caused by the appsettings.json file format.
Read more >
Create an ASP.NET Core app with React in Visual Studio
Learn how to get started with the ASP.NET Core Single Page Application (SPA) project template for React and Create React App (CRA).
Read more >
Error fetching data from ASP.NET in ReactJS
I'm using ReactJS with functional components for my front-end trying to fetch data from the ASP.NET WebService, from File.jsx const URL ...
Read more >
Tutorial (ASP.NET Core)
This tutorial covers the end-to-end process of creating a brand new ASP.NET MVC website and adding a React component in it. We will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found