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.

Simplify package.json inference

See original GitHub issue

Following up on https://github.com/electron-userland/electron-packager/pull/449#issuecomment-240865736

Currently there’s a bit of code in index.js that uses get-package-info to look for package.json files from which to infer default values for electron version, product name, etc. This technique of recursing up directories can produce unpredictable results depending on the directory structure of a given user.

As @malept said:

Not that I want to drag this PR out any longer, but should we have a test for the case where no app-version is specified and (for some reason) there is no version in any of the package.json files found?

Looking for the first parent package.json file instead of all parent package.json files will enable us to reliably test that scenario. Writing up this issue because I came across a battle-tested package that does what we want: https://www.npmjs.com/package/find-root

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
rahatarmanahmedcommented, Oct 12, 2016

Ok, published 1.0.0 of get-package-info, which now returns a better error that lets us know when props can’t be found.

From the README:

If all the properties cannot be found in parent package.json files, then getPackageInfo() will reject it’s promise (or callback with err argument) with an Error. err.missingProps will have an array of the properties that it could not find, and err.result will contain all the props that were found.

If any other error occurs(like I/O or runtime errors), getPackageInfo() will reject with that error itself.

I’ll work on a PR using this new info later tonight.

0reactions
maleptcommented, Oct 13, 2016

There have been a couple of pull requests that make adding electron (FKA electron-prebuilt) not required to be set in dependencies or devDependencies, nor set via --version (although no one’s actually finished any of the PRs). I’m a bit conflicted about whether that is a good default. Offhand, it seems dangerous, given that basically defaults the dependency to "electron": "*".

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simplifying package.json of backward-compatible ... - GitHub
As asked by @GeoffreyBooth in #323 I'm opening new issue for this discussion The "type": "module" solution for publishing MJS modules had an ......
Read more >
Create a package.json File - YouTube
In this tutorial, we'll: -Create a package. json file using npm init ... the best online Node.js courses and tutorials to help you...
Read more >
Specifying dependencies in Node.js - Cloud Functions
Dependencies in Node.js are managed with npm and expressed in a metadata ... To specify a dependency for your function, add it to...
Read more >
Yarn: A new package manager for JavaScript
With no arguments, the yarn command will read your package.json , fetch packages from the npm registry, and populate your node_modules folder.
Read more >
Announcing TypeScript 4.7 Beta - Microsoft Developer Blogs
Node.js supports a new setting in package.json called type . ... TypeScript 4.7 can now perform more granular inferences from functions ...
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