electron:build command does not copy project package.json - no node modules installed
See original GitHub issueWhen running electron:build
, the project package.json in the root directory is not copied to the dist_electron/bundled
folder and no dependencies are installed. Running the built executable results in a lot of module <name> not found
errors in the console.
Steps to reproduce the behavior:
- Create a new Vue 2 project with the Vue CLI ->
vue create <name>
- Add this plugin as per the docs ->
vue add electron-builder
- Install any node package. For example,
yarn add node-fetch
- Use this package in any of the source files.
- Build the app with
yarn electron:build
- Run the built .exe and check the console. You will see a missing module for that package error. To further verify this, extracting the
app.asar
in thedist_electron/win-unpacked/resources
folder and opening the output folder will show you none of your installed node modules in the dependencies section of your package.json are copied over.
Expected behavior
All packages in the dependencies
section of the project package.json should be copied over when building the project.
Environment:
- Windows 10
- Yarn (but same problem with NPM)
- “vue-cli-plugin-electron-builder”: “~2.0.0-rc.6”
- “electron”: “^11.0.0”
Additional context I original encountered this error in a project I had been working on for months and it appeared within the last couple days. Tried this with just a basic Vue project created with the CLI and only modified the background.js file to use the node-fetch package I had installed. Same problem.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
npm - Electron-Builder does not copy node_modules into my ...
I have an electron app with the following structure - dist | - index.html | - node_modules | - nm (is an exact...
Read more >Cannot find module after installing @electron/build-tools on Arch
I just ran npm install -g @electron/build-tools on Arch LInux and got this error after rehashing in zsh and running e init --root=~/electron...
Read more >Packaging Electron (Nodejs) Application (along with Flask ...
... of npm. The package can be installed using the following command: ... This gets covered when the project is initiated with package.json....
Read more >Common Configuration - electron-builder
in the package.json file of your project using the build key on the top level: ... If you want to use js file,...
Read more >Manage npm packages - Visual Studio (Windows)
json file, you can add one to enable npm support by adding a package.json file to the project. If you don't have Node.js...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, you should use es6
import
statements actually. Webpack automatically bundles all your deps together for you.Try adding a
vue.config.js
file with this in it:See the docs on native modules for more details on the
externals
property.