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

How to use single package.json structure #601

Closed
amilajack opened this issue Jul 19, 2016 · 21 comments
Closed

How to use single package.json structure #601

amilajack opened this issue Jul 19, 2016 · 21 comments
Labels

Comments

@amilajack
Copy link

amilajack commented Jul 19, 2016

The docs describe how to use the two package.json structure. However, when following this structure, I came across dlopen issues. How can I use a single package.json structure?

In my package.json, I have the following:

  build": {
    "appId": "...",
    "app-category-type": "public.app-category.video",
    "win": {
      "iconUrl": "..."
    }
  },
  "directories": {
    "app": ".",
    "output": "release"
  }

Upon package, however, I get an error saying that my main.js file cannot be found.

@develar
Copy link
Member

develar commented Jul 19, 2016

Do not specify app directory as . Just not specify it.

when following this structure, I came across dlopen issues.

Please provide more details or sample project. Maybe related: https://github.com/electron-userland/electron-builder/wiki/Loading-App-Dependencies-Manually

@develar develar closed this as completed Jul 19, 2016
develar added a commit to develar/electron-builder that referenced this issue Jul 19, 2016
@ff6347
Copy link

ff6347 commented Jul 26, 2016

It would be great to have some more info on using just a single package.json file

@develar
Copy link
Member

develar commented Jul 26, 2016

@fabiantheblind You can see project https://github.com/nodejs/installer It is single package.json file project.

@ff6347
Copy link

ff6347 commented Jul 26, 2016

Thank you @develar

@ff6347
Copy link

ff6347 commented Jul 26, 2016

@develar I did it exactly like this but I'm running into an issue with that:

> frontal@0.5.0 dist /Users/me/path/to/my/project/root
> build

Error: ENOENT: no such file or directory, open '/Users/me/path/to/my/project/root/app/package.json'
    at Error (native)
From previous event:
    at Packager.<anonymous> (/Users/me/path/to/my/project/root/node_modules/electron-builder/src/packager.ts:73:55)
    at next (native)
    at runCallback (timers.js:566:20)
    at tryOnImmediate (timers.js:546:5)
    at processImmediate [as _immediateCallback] (timers.js:525:5)
From previous event:
    at tsAwaiter (/Users/me/path/to/my/project/root/node_modules/electron-builder/src/util/awaiter.ts:10:47)
    at Object.build (/Users/me/path/to/my/project/root/node_modules/electron-builder/src/builder.ts:193:52)
    at Object.<anonymous> (/Users/me/path/to/my/project/root/node_modules/electron-builder/src/build-cli.ts:27:28)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)
    at bootstrap_node.js:467:3

looks like the same issue as #600

@develar
Copy link
Member

develar commented Jul 26, 2016

@fabiantheblind Yes, it is #600

@ff6347
Copy link

ff6347 commented Jul 26, 2016

@develar thanks. I renamed my app folder and now run into errors of mismatching native modules

Error: Module version mismatch. Expected 48, got 49.

So the solution is to just use 2 package.json files instead I guess. #39 (comment)

@develar
Copy link
Member

develar commented Jul 26, 2016

@fabiantheblind If you have native modules — yes, you should use 2 package.json structure.

@ff6347
Copy link

ff6347 commented Jul 26, 2016

Last question:

For quick testing before restructuring my project with 2 package.json.

How to find out which node version electron uses so I can use nvm to make a test on my machine?

@develar
Copy link
Member

develar commented Jul 26, 2016

How to find out which node version electron uses so I can use nvm to make a test on my machine?

You don't need. Your unpacked electron app uses the same version of node as packed. So, just use electron-prebuilt or unpacked app.

@ff6347
Copy link

ff6347 commented Jul 26, 2016

hm. I'm using electron-prebuilt already. Anyway thanks a lot for the quick help. I will switch to 2 package.json files

@akashnimare
Copy link
Contributor

@fabianmoronzirfas @develar did it work with single package.json?

@develar
Copy link
Member

develar commented Oct 11, 2016

@akashnimare What do you mean?

@ff6347
Copy link

ff6347 commented Oct 11, 2016

@akashnimare I work with 2 package.json anything else makes my head hurt

@akashnimare
Copy link
Contributor

akashnimare commented Oct 11, 2016

@fabianmoronzirfas haha. I have only one json file in my app. Could you tell me what changes I need to do to make it work (app structure wise etc) ?

@ff6347
Copy link

ff6347 commented Oct 11, 2016

Check out this project. https://github.com/frntl/frontal Actually you only need to have a package.json in the root of your project and another in your app folder. The one in the app folder or holds all of the dependencies. The one in the root of your project hold your development dependencies.

@develar
Copy link
Member

develar commented Oct 12, 2016

@akashnimare "to make it work" is not clear. Please file new issue and describe — doesn't build (error?) or doesn't run after build (error?). Sorry, but my free time is limited and it is not wise to investigate if no clear error description.

@akashnimare
Copy link
Contributor

@develar Sorry if I was not clear. I'm currently trying as @fabianmoronzirfas suggested and will let you know if I have any issue. Thanks for the help.

@omenking
Copy link

omenking commented Dec 11, 2017

Same problem. I thought maybe I could set:

    "directories" : {
      "app" : ".",
      "buildResources" : "static"
    },

Though getting error that results as such

Using node_modules/electron-webpack/electron-builder.yml configuration file
⚠️  Specified application directory "." equals to project dir — superfluous or wrong configuration
Rebuilding native production dependencies for darwin:x64
Packaging for darwin x64 using electron 1.7.9 to dist/mac
Error: Application entry file "main.js" in the "/Users/andrew/Sites/swap-n-pop/dist/mac/swap-n-pop.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.

I tried reading through the codebase to understand how electron-builder assembles the asar file and how it uses these build options but there was so much abstraction I couldn't tell what was going on.

The docs suggest you can do a single package.json build though no example

Since version 8 electron-builder rebuilds only production dependencies, so, you are not forced to use two package.json structure.

I used to have two package json structure though one of my devs changed it to one. I figured there was some way to configure exactly what would get packed into the asar though the configuration options don't appear very robust.

This was suggested to have a single package file as an example
https://github.com/nodejs/installer
though it appears they are now using electron-forge

@develar
Copy link
Member

develar commented Dec 11, 2017

@omenking What file is specified as main in your package.json?

@omenking
Copy link

if you mean what is set to entry its main.js

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

No branches or pull requests

5 participants