error that when i run builded electron program
the program operate well in my computer but,when i build by 'electron-builder --win portable' and move to other computer then the error occured. (coding in window 11, test in window 10)
how do i fix it?
package.json
"scripts": {
"build:renderer": "webpack --config ./client/webpack.config.renderer.js",
"build:main": "tsc --project ./client/tsconfig.json",
"build": "npm run build:main && npm run build:renderer",
"build:addon:x86": "(cmake-js -G \"Visual Studio 16 2019\" -A Win32 -O build_Win32)",
"build:addon:x64": "(cmake-js -G \"Visual Studio 16 2019\" -A x64 -O build_x64)",
"start": "electron . --enable-logging",
"copy_binary": "copy_binary.bat",
"dist": "electron-builder --win portable"
},
"devDependencies": {
"cmake-js": "^7.0.0",
"electron-rebuild": "^3.2.7",
"ts-loader": "^9.4.1",
"typescript": "^3.1.0",
"webpack": "^5.74.0",
"electron": "16.0.10",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"node-addon-api": "^4.1.0"
},
"cmake-js": {
"runtime": "electron",
"runtimeVersion": "16.0.10"
}
i tried that...
add "postinstall": "electron-builder install-app-deps" in package.json
add set(DELAY_LOAD_HOOK "hook/win_delay_load_hook.cc") in cmakelists.txt
I managed to fix it copying the old binding.gyp file and ran electron-rebuild, the new .node file will be here .\electron-overlay\bin\win32-x64-109
Related
after the command "npm start" I do not see changes in the console, as if the code is not being updated on the fly.
{
"scripts": {
"format": "prettier --write app",
"start": "http-server"
},
"dependencies": {
"http-server": "^14.1.0"
},
"devDependencies": {
"prettier": "^2.0.5"
}
}
My version of node: 7.11.1
i have a macbook
What can I do ?
Thank you
Node do not automatically restart after changes :)
You should use eg. nodemon:
https://www.npmjs.com/package/nodemon
npm i nodemon --dev
Then start your app like that:
nodemon index.js
donnot reload your page.
you can use eg. nodemon: https://www.npmjs.com/package/nodemon
Thank you for your help, but it still doesn't go ... I installed a nodemon. {
"scripts": {
"format": "prettier --write app",
"start": "http-server"
},
"dependencies": {
"http-server": "^14.1.0"
},
"devDependencies": {
"nodemon": "^2.0.16",
"prettier": "^2.0.5"
}
}
then I have to in the console: nodemon game.js ?
I have created an electron project which is working fine but when I try to package an electron app using electron packager and then run it. I am facing an exception
Uncaught Exception:
Error: Cannot find module
Require stack
'E:\app-folder..release-builds\app-win32-ia32\resources\app....\node_sqlite3.node'
click here to see Error
'Here is my package.json'
{
"name": "app",
"version": "1.0.0",
"main": "main.js",
"devDependencies": {
"electron": "^8.2.0",
"electron-builder": "^22.8.0",
"electron-rebuild": "^1.10.1"
},
"scripts": {
"start": "electron .",
"rebuild": "electron-rebuild -f -w sqlite3",
"package-win": "electron-packager . App--overwrite --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"App\"",
"postinstall": "electron-builder install-app-deps"
},
"dependencies": {
"axios": "^0.19.2",
"concat-stream": "^2.0.0",
"datatables.net": "^1.10.20",
"datatables.net-dt": "^1.10.20",
"ejs": "^3.1.5",
"electron-packager": "^15.0.0",
"express-validator": "^6.6.1",
"form-data": "^3.0.0",
"jquery": "^3.5.0",
"nodemailer": "^6.4.11",
"sqlite3": "^5.0.0"
}
}
npm install --save-dev #electron-forge/cli
npm run package
try running these commands you will get an out folder and the application is present in that out folder
So I have a typescript project hosted on github.
I'm trying to set up Travis CI for tests but when I get to the step to compile the code to javascript (tsc command) it fails.
The error looks like this:
> node node_modules/typescript/bin/tsc
src/DbHandler.ts:2:32 - error TS2307: Cannot find module './models/User'.
2 import { User, UserInit } from './models/User';
~~~~~~~~~~~~~~~
src/User.ts:2:22 - error TS2307: Cannot find module './models/User'.
2 import { User } from "./models/User";
~~~~~~~~~~~~~~~
Found 2 errors.
npm ERR! code ELIFECYCLE
The paths to the files ARE correct and it compiles just fine locally..
In the project I have this package.json(cleaned):
{
"name": "project",
"version": "0.0.1",
"description": "",
"main": "dist/server.js",
"scripts": {
"build": "node node_modules/typescript/bin/tsc",
"prod": "node dist/server.js",
"dev": "ts-node src/server.ts",
"dev:watch": "nodemon",
"test:watch": "ts-node node_modules/jasmine/bin/jasmine",
"test": "node node_modules/jasmine/bin/jasmine.js --config=jasmine.json"
},
"author": "myname",
"license": "MIT",
"devDependencies": {
"#types/express": "~4.17.1",
"#types/jasmine": "~3.4.4",
"jasmine": "~3.5.0",
"nodemon": "~1.19.4",
"ts-node": "~8.4.1",
"tslint": "~5.20.0",
"typescript": "~3.6.4"
},
"dependencies": {
"express": "~4.17.1"
}
}
And my .travis.yml looks like:
language: node_js
cache: npm
node_js:
- "stable"
install:
- npm ci
- npm run build
script:
- npm run test
And my file structure is something like this:
package.json
.travis.yml
src/
models/
User.ts
DbHandler.ts
User.ts
server.ts
test/
files_for_tests_with_ts_extension
I am using webpack and babel in my project. While the webpack is wokring fine but babel is somehow not doing it's job in polyfilling the ES6+ features. When I use the npm script, I get some error "Entrypoint undefined = index.html" in the command prompt. Kindly help !
Package.json
{
"name": "forkify",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open"
},
"author": "neeraj",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^8.0.2",
"babel-preset-env": "^1.7.0",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.19.0",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.8"
},
"dependencies": {
"babel-polyfill": "^6.26.0"
}
}
webpack.config.js
const path=require('path');
const HtmlWebPackPlugin=require('html-webpack-plugin');
module.exports={
entry:['babel-polyfill','./src/js/index.js'],
output:{
path:path.resolve(__dirname,'dist'),
filename:'js/bundle.js'
},
devServer:{
contentBase:'./dist'
},
plugins:[
new HtmlWebPackPlugin({
filename:'index.html',
template:'./src/index.html'
})
],
module:{
rules:[
{
test:/\.js$/,
exclude:/node_modules/,
use:{
loader:'babel-loader'
}
}
]
}
};
.bablerc
{
"presets":[
["env",{
"targets":{
"browser":[
"last 5 versions",
"ie>=8"
]
}
}]
]
}
Error what I get:
Project Structure:
EDIT------------------
I started getting some new error now.
It is the html-webpack-plugin's problem, a fix was introduced in
3.0.7 but was removed again in 3.0.8. For more information, please click here.
So if you run npm install --save-dev html-webpack-plugin#3.0.7, and then npm run dev will output Entrypoint html-webpack-plugin for "index.html" = index.html. And personally, it is a trivail problem not that important.
There was some dependency issue. Deleted my node_modules folder and used this command instead: npm install -D babel-loader#7 babel-core babel-preset-env webpack
Follow this link for more information : https://github.com/babel/babel-loader
Now I no longer get any error and also babel is working fine.
FYI....you might have to install babel-polyfill & html-webpack-plugin seperately.
I have a project that consists of server side code (in nodejs) and client side code (with react). I have separate package.json files for those but I was asked to merge them into one. Server file is in the project root dir, client side is in /client folder with the rest of client code. Could you help me to do that? May I just copy client file to server client with some modification? I cannot find anything useful on it.
package.json:
{
"name": "curr-calc",
"version": "1.0.0",
"description": "currency calc using node.js and react.js",
"main": "index.js",
"repository": "",
"author": "",
"license": "MIT",
"scripts": {
"client": "cd client && yarn start",
"server": "nodemon server.js",
"dev": "concurrently --kill-others-on-fail \"yarn server\" \"yarn client\"",
"lint": "eslint .",
"babel": "babel --presets es2015 js/server.js -o build/main.bundle.js",
"test": "yarn --cwd client run test",
"heroku-postbuild": "cd client && yarn --production=false && yarn run build"
},
"dependencies": {
"body-parser": "^1.18.2",
"express": "^4.16.2",
"express-session": "^1.15.6",
"node-fetch": "^2.1.2",
"open": "0.0.5",
"path": "^0.12.7",
"prop-types": "^15.6.1",
"react-widgets": "^4.2.6",
"redis": "^2.8.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.3",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"concurrently": "^3.5.0",
"eslint": "^4.19.1",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-react": "^5.0.0",
"eslint-plugin-import": "^2.6.0",
"eslint-plugin-jest": "^21.3.2",
"eslint-plugin-node": "^5.1.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.5.1",
"eslint-plugin-standard": "^3.0.1",
"fetch-mock": "^6.3.0",
"node-fetch": "^2.1.2",
"nodemon": "^1.17.2",
"react-test-renderer": "^16.3.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1"
}
}
client/package.json:
{
"name": "curr-calc",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-scripts": "1.1.1"
},
"devDependencies": {
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"fetch-mock": "^6.3.0",
"react-test-renderer": "^16.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000/"
}
EDIT:
I tried to merge this manually:
1) I copied all dependencies
2) I copied srcipts and renamed those duplicated and add "cd client && " to the beginning of every client script
3) I removed package.json, node_modules and all yarn files from clien folder
Now when I try to run the app by yarn dev I receive:
Listening on port 5000 [1] module.js:549 [1] throw err; [1] ^
[1] [1] Error: Cannot find module
'/home/zaba/code/currCalc_react/curr-calc/client/package.json' [1]
at Function.Module._resolveFilename (module.js:547:15) [1] at
Function.Module._load (module.js:474:25) [1] at Module.require
(module.js:596:17) [1] at require (internal/module.js:11:18) [1]
at getPublicUrl
(/home/zaba/code/currCalc_react/curr-calc/node_modules/react-scripts/config/paths.js:34:19)
[1] at Object.
(/home/zaba/code/currCalc_react/curr-calc/node_modules/react-scripts/config/paths.js:61:14)
[1] at Module._compile (module.js:652:30) [1] at
Object.Module._extensions..js (module.js:663:10) [1] at
Module.load (module.js:565:32) [1] at tryModuleLoad
(module.js:505:12) error An unexpected error occurred: "Command
failed. [1] Exit code: 1 [1] Command: sh [1] Arguments: -c cd client
&& react-scripts start [1] Directory:
/home/zaba/code/currCalc_react/curr-calc [1] Output: [1] ". info If
you think this is a bug, please open a bug report with the information
provided in "/home/zaba/code/currCalc_react/curr-calc/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about
this command. error An unexpected error occurred: "Command failed. [1]
Exit code: 1 [1] Command: sh [1] Arguments: -c yarn start [1]
Directory: /home/zaba/code/currCalc_react/curr-calc [1] Output: [1] ".
info If you think this is a bug, please open a bug report with the
information provided in
"/home/zaba/code/currCalc_react/curr-calc/yarn-error.log". info Visit
https://yarnpkg.com/en/docs/cli/run for documentation about this
command. [1] yarn client exited with code 1
--> Sending SIGTERM to other processes.. [0] yarn server exited with code null error An unexpected error occurred: "Command failed. Exit
code: 1 Command: sh Arguments: -c concurrently --kill-others-on-fail
\"yarn server\" \"yarn client\" Directory:
/home/zaba/code/currCalc_react/curr-calc Output: ". info If you think
this is a bug, please open a bug report with the information provided
in "/home/zaba/code/currCalc_react/curr-calc/yarn-error.log".
Why is it still looking for client/package.json file? Can that be create-react-app setting hidden somewhere?
I would not merge those into one. They are two different applications and have different dependencies. I'd namespace the names though like this: #curr-calc/client and #curr-calc/server.
If you really wanted to merge them, I'd do that manually by just copying over the dependencies, devDependencies and scripts. Remove any duplicates (in case of scripts you'll need to rename those who have duplicate keys).
You have several approaches here, depending on your goals:
Merge it manually, along with the two projects - then you'll have a single project with a single package.json file.
Since json is just a plain JS object, you can use something like lodash's merge to achieve that:
const server = require("../path/to/server/package.json");
const client = require("../path/to/client/package.json");
const merge = require("lodash/fp/merge");
let merged = merge(server, client);
more information about lodash-fp and node can be found here