App cannot be build due to an error parsing the dependencies of the package.json file
See original GitHub issueBug 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:
- Created 4 years ago
- Comments:12 (4 by maintainers)
Top GitHub Comments
I will go ahead and close out this ticket since this is not a bug.
The reason why Cordova Electron build, specifically the prepare step, needs the
package.json
is because it fetches the list of defineddependencies
to copy them inside the Electron’spackage.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.