I create desktop application by using electron, and tried electron-packager.
But electron-packager doesn't package node modules which names are started from "#" (Example: #turf, #mapbox)
In node_modules folder of developing folder, I can find "#turf" and "#mapbox".
But after running
>electron-packager . MaplatEditor --platform=darwin --arch=x64 --electron-version=1.7.9
Created package never includes "#turf" and "#mapbox".
And also, it's depending modules are also not included.
My package.json includes "#turf", so it is not setting error.
{
"name": "MaplatEditor",
"version": "1.0.0",
"description": "",
"main": "lib/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#turf/turf": "^4.6.1",
"argv": "0.0.2",
"async": "^2.5.0",
"child_process": "^1.0.2",
"electron-json-storage": "^3.2.0",
"file-url": "^2.0.2",
"fs-extra": "^3.0.1",
"imagemagick": "^0.1.3",
"mapshaper": "^0.4.31",
"path": "^0.12.7",
"wellknown": "^0.5.0"
}
}
How can I package such #-started modules into application package?
In my case, I updated #Turf module for latest version, then electron-packager worked well.
I don't know why, but it looks not the issue of electron-packager...
Related
After building the electron application using electron-builder, I cannot open the application from the dist folder. I did change all my links to use path.join(__dirname, "relative_path/") as what I have seen in some answers here. But I can't open the application even though the packaging process is successful.
File structure for the electron app project
Here's an image of my file structure, and this is the package.json file of the project
{
"name": "my_little_reminder",
"version": "0.5.0",
"description": "A simple time reminder app",
"main": "src/index.js",
"scripts": {
"start": "electron .",
"test": "jest --coverage",
"build": "electron-builder --dir"
},
"author": "Leonlit",
"license": "MIT",
"dependencies": {
"node-notifier": ">=8.0.1",
"node-schedule": "^1.3.2",
"sqlite3": "^5.0.0",
"electron-log": "^4.3.1"
},
"devDependencies": {
"electron": "^11.2.1",
"electron-builder": "^22.9.1",
"jest": "^26.6.3"
}
}
Finally, here's a link to the repository if the information here is not enough, https://github.com/Leonlit/My-Little-Reminder/tree/development
Resolved the issue by adding and using the npm script "postinstall": "electron-builder install-app-deps".
Then, using path.join(app.getPath('userData'), '/tasks.db') instead of path.join(__dirname, '/tasks.db') for the sqlite database storage location.
Finally, changed a link in the index file which caused the application to always request for saving a ASAR file on app launch if left unfixed.
Electron app was initialized using electron-forge webpack template and everything works perfectly for macOs.
While running the dev version using electron-forge start the app loads perfectly on windows.
Once the app is packaged for windows using electron-forge make the build completes successfully. But while running the packaged app Cannot find module X is thrown.
The folder ./out/app/resources/app/node_modules is empty.
Also the package.json ./out/app/resources/app/package.json looks as follows.
"name": "my-app",
"productName": "my-app",
"version": "1.0.0",
"description": "My Electron application description",
"main": ".webpack/main",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "",
"email": ""
},
"license": "MIT",
"config": {},
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {},
"peerDependencies": {}
}
None of the dependencies in the source package.json made it to the packaged app.
Try this
cd "my-app"
:: install dependency into your node_modules and update your package.json
npm install your-dependency --save-prod
npm run make
I've been having this issue for a while and I've even opened an issue on electron-builder github page but haven't received any response.
I'm running electron builder version 20.38.4 and trying to package the app for Win 64 environment. Everything works fine when I do "yarn dev" and "yarn compile". Even "yarn dist" works without any issue.
However, when I click on the generated .exe file, I get this error message.
Any ideas?
Here's the link to the issue I've opened with some detailed screenshots and log outputs
https://github.com/electron-userland/electron-builder/issues/3561
Here's the package.json as requested
{
"name": "myproj",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"dev": "electron-webpack dev",
"compile": "electron-webpack",
"dist": "yarn compile && electron-builder",
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null"
},
"dependencies": {
"#rodrigogs/mysql-events": "^0.5.2",
"electron-online": "^1.0.0",
"mysql": "^2.16.0",
"source-map-support": "^0.5.9"
},
"devDependencies": {
"electron": "3.0.10",
"electron-builder": "^20.38.4",
"electron-webpack": "^2.6.1",
"webpack": "^4.26.0"
},
"build": {
"appId": "com.teamio.app",
"productName": "Teamio",
"buildVersion": "1.0",
"copyright": "Copyright © 2018 Teamio.app",
"nsis": {
"oneClick": false,
"perMachine": true,
"allowElevation": true,
"allowToChangeInstallationDirectory": true,
"deleteAppDataOnUninstall": true,
"createDesktopShortcut": true,
"installerIcon": "build/icon.ico",
"uninstallerIcon": "build/icon.ico",
"uninstallDisplayName": "Uninstall Teamio"
},
"win": {
"target": "nsis",
"icon": "build/icon.ico"
}
}
}
Sorry to revive an old question, but what is happening is the electron-online package does not properly define its dependencies in its own package.json. So it is missing the debug package, which you have "solved" by placing another package that requires debug in your project dependencies. In reality though, the (long abandoned) package electron-online should update its dependencies and add debug, among others.
As a slightly cleaner workaround, you could add debug to your project dependencies instead of electron-webpack or webpack.
I had the same problem a few hours ago, resolved by not excluding (ignoring) the src folder from package config. Could you paste you package.json file here ?
Ok. Looks like I've solved my own problem. Not sure why exactly but it worked. What I had to do was move 2 dependencies listed below from devDependencies to dependencies section in my package.json
"electron-webpack": "^2.6.1",
"webpack": "^4.26.0"
If someone can shed some light on that, it'd be helpful. I figured I'd post it here in case someone else runs into this issue.
I have some problems when i try to run my app on phones that have iOS, but in Android don't have this problem. I'm coding in Sublime Text, not in XDE and executing my project in terminal, with commands npm start and reading the QR Code. I'm coding in Windows 10.
I build the project with create-react-native-app
The erro that appears is
C:/Users/adria/Desktop/App/src/Imgs/image.png: Cannot find module
'C:/Users/adria/Desktop/App/node_moduless/expo/tools/hashAssetFiles'
In the first time i did think that image is with wrong name or wrong directory, and i go to the code and certify that is correctly. So, i resolve to try in my Android and for my surprise, work correctly.`
My project:
[https://snack.expo.io/HyKP1hyjz][1]
My package.json
{
"name": "App",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.11.1",
"jest-expo": "25.0.0",
"react-test-renderer": "16.2.0"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js" },
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"expo": "^25.0.0",
"react": "16.2.0",
"react-native": "0.52.0",
"react-navigation": "^1.5.8"
}
}
I try to remove the image from my project and try run again, and have the same problem but with another image, from react-navigation
C:\Users\adria\Desktop\App\node_modules\react-navigation\src\views\assets\back-icon.png
You'll need to have the exponent package installed, see: https://github.com/expo/expo/issues/72
I have created a sample Electron App and i need to create a .exe file from it. I managed to build the app without errors but when i start the app an error appears.I cant figure out why im getting this.How to resolve this?.
The Error im getting
My package.json file
{
"name": "wordsum",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron main.js",
"package-mac": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=App/assets/WSlogo.icns --prune=true --out=release-builds",
"build": "electron-packager . --overwrite --asar=true --platform=win32 --arch=ia32 --icon=App/assets/WSlogo.ico --prune=true --out=release-builds --version-string.CompanyName=DevX --version-string.FileDescription=DevX --version-string.ProductName=\"WordSum\"",
"package-linux": "electron-packager . --overwrite --platform=linux --arch=x64 --icon=App/assets/WSlogo.png --prune=true --out=release-builds"
},
"author": "Thaaraka Romesh",
"license": "MIT",
"dependencies": {
"angular": "^1.6.2",
"bootstrap": "^3.3.7",
"jquery": "^3.1.1"
},
"devDependencies": {
"electron": "^1.4.15",
"electron-packager": "^8.5.1"
}
}
The Repo of the project Electron project
I found out whats wrong. In my package.json file its mentioned as "main": "index.js" but im my app the actual main file is called main.js.