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.

App cannot be build due to an error parsing the dependencies of the package.json file

See original GitHub issue

Bug Report

Problem

The app cannot build properly due to an error, apparently, when process the “package.json” file.

What is expected to happen?

The app must be successfully build, even if there are some nodejs / electron modules dependencies.

What does actually happen?

When the app starts to build, a “package.json” file is prepared with lot of modules inside the “dependencies” key of the JSON file.

For simplification, below is a “package.json” which only contains one dependency, however, even with this one, the app cannot be build properly.

{
  "requires": true,
  "lockfileVersion": 1,
  "dependencies": {
    "7zip-bin": {
      "version": "4.1.0",
      "resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-4.1.0.tgz",
      "integrity": "sha512-AsnBZN3a8/JcNt+KPkGGODaA4c7l3W5+WpeKgGSbstSLxqWtTXqd1ieJGBQ8IFCtRg8DmmKUcSkIkUc0A4p3YA=="
    }
  }
}

The first line of the error than appear (sorry, I try, but can’t insert here more error output without break the apparence of the post dramatically…) is the below one:

node_modules.Dependency.Dependencies: ReadString: expects " or n, but found {, error found in #10 byte of …|ip-bin

If we manually remove the dependencies, that is, if we prepare the “package.json” file like below:

{
  "requires": true,
  "lockfileVersion": 1,
  "dependencies": {}
}

Then the app build successfully, however, I think the dependencies means “node/electron modules ready to be used”, and, certainly, we want to use some of these modules… so can’t simply remove the dependencies from the “package.json” file.

Information

I am not sure if this problem is just for me… I try updating node js, use the latest Cordova version and the latest Cordova Electron version too.

Command or Code

In fact I always can reproduce the problem, however, as I mentioned above, I am not sure if this problem is just for me or what… 😦

Environment, Platform, Device

I try to compile the app in Windows 10 64 bits.

Version information

Cordova version: 9.0.0

Cordova Electron version: 1.1.1

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above (I hope! But please, ask me for anything else!)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
erisucommented, Jan 12, 2020

I will go ahead and close out this ticket since this is not a bug.

1reaction
erisucommented, Jan 12, 2020

The reason why Cordova Electron build, specifically the prepare step, needs the package.json is because it fetches the list of defined dependencies to copy them inside the Electron’s package.json.

It is done this way so you can have NPM dependencies available for your Electron project. This process does not exist in iOS or Android as they can not use NPM packages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm "failed to parse json" - Stack Overflow
Mostly, this error is due to a syntax error in package.json file. In my case, the opening curly brace for dependencies object in...
Read more >
package.json - npm Docs
When this package is installed as a dependency in another package, the file will be linked where it will be available to that...
Read more >
Using Node.js Modules with Azure applications - Microsoft Learn
After the application has been deployed, the npm install command is used to parse the package.json file and install all the dependencies listed....
Read more >
Read/Write JSON Files with Node.js | heynode.com
Learn to use fs module to interact with the filesystem; Persist data to a JSON file; Use JSON.parse and JSON.stringify to convert data...
Read more >
Project import errors – Support Portal | Snyk
This can often happen when processing Bill of Material pom files, which do not contain any of their own dependencies but specify package...
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