Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: find the real parent node module #132

Merged
merged 4 commits into from
Sep 11, 2024

Conversation

beyondkmp
Copy link
Contributor

@beyondkmp beyondkmp commented Sep 11, 2024

fix electron-userland/electron-builder#8426

package.json

{
  "name": "npm-demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
     "parse-asn1":"5.1.7"
  }
}

error in macOS/linux

 ../../../app-builder  node-dep-tree --flatten --dir ~/Code/app-builder/pkg/node-modules/npm-demo
  ⨯ stat /root/Code/app-builder/pkg/node-modules/npm-demo/node_modules/parse-asn1/asn1.js/package.json: not a directory
github.com/develar/app-builder/pkg/node-modules.(*Collector).resolveDependency
        /root/Code/app-builder/pkg/node-modules/nodeModuleCollector.go:236
github.com/develar/app-builder/pkg/node-modules.(*Collector).processDependencies
        /root/Code/app-builder/pkg/node-modules/nodeModuleCollector.go:122
github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
        /root/Code/app-builder/pkg/node-modules/nodeModuleCollector.go:64
github.com/develar/app-builder/pkg/node-modules.(*Collector).readDependencyTree
        /root/Code/app-builder/pkg/node-modules/nodeModuleCollector.go:80
github.com/develar/app-builder/pkg/node-modules.ConfigureCommand.func1
        /root/Code/app-builder/pkg/node-modules/tree.go:41
github.com/alecthomas/kingpin.(*actionMixin).applyActions
        /root/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/actions.go:28
github.com/alecthomas/kingpin.(*Application).applyActions
        /root/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:557
github.com/alecthomas/kingpin.(*Application).execute
        /root/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:390
github.com/alecthomas/kingpin.(*Application).Parse
        /root/go/pkg/mod/github.com/alecthomas/[email protected]+incompatible/app.go:222
main.main
        /root/Code/app-builder/main.go:90
runtime.main
        /usr/local/go/src/runtime/proc.go:272
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1700

error in window

../../../app-builder.exe node-dep-tree --flatten --dir ~/Code/app-builder/pkg/node-modules/npm-demo                                              
dir C:\Users\beyon\Code\app-builder\pkg\node-modules\npm-demo\node_modules\parse-asn1\asn1.js C:\Users\beyon\Code\app-builder\pkg\node-modules\npm-demo\node_modules\parse-asn1\asn1.js\package.json [] open C:\Users\beyon\Code\app-builder\pkg\node-modules\npm-demo\node_modules\parse-asn1\asn1.js\package.json: The system cannot find the path specified.

root cause

In this PR(#89), it only searches for FindParentWithFile but doesn't verify if it's a folder or if it contains a package.json

On Windows, it returns IsNotExist, so it directly returns nil. On macOS/Linux, it returns not a directory, so it directly returns an error, causing the crash.

if os.IsNotExist(err) {

Copy link

changeset-bot bot commented Sep 11, 2024

🦋 Changeset detected

Latest commit: 2ff062f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
app-builder-bin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error in rebuilding native dependency on win10
3 participants