npm run dev won't start server - node.js

I'm trying to do a "npm run dev", but it's not starting a server. I thought that it was supposed to and open up http://127.0.0.1:8000. How do I get it to do that? "npm start" works and goes to my localhost. I looked for an answer, but couldn't find anything. If anyone can help me out or give me a link to an answer, I'd appreciate it. I'm new here. Thanks. If it helps:
npm -v
6.4.1
node -v
v10.13.0
webpack -v
4.20.2
package.json:
{
"name": "cocos-skeleton",
"description": "",
"version": "1.0.0",
"main": "main.js",
"author": "",
"license": "UNLICENSED",
"private": true,
"repository": {
"type": "git",
"url": ""
},
"scripts": {
"lint": "cross-env eslint src",
"test": "cross-env jest --passWithNoTests",
"test:watch": "cross-env jest --passWithNoTests --watch --notify",
"test:coverage": "cross-env jest --coverage",
"config": "cross-env webpack --config tools/webpack/webpack.config.js",
"bundle": "cross-env npm run config -- --mode production",
"bundle:watch": "cross-env npm run config -- --mode development --watch --progress --display-error-details",
"compile": "cross-env cocos compile",
"start": "cross-env cocos run",
"dev": "cross-env npm run bundle:watch & npm run start",
"refresh": "cross-env npm run compile && npm run start",
"release": "cross-env cocos run -m release"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"linters": {
"*.js": [
"eslint --fix",
"jest --bail --findRelatedTests",
"git add"
]
},
"ignore": [
"**/frameworks/**/*.js"
]
},
"dependencies": {
"#babel/polyfill": "^7.0.0",
"howler": "^2.0.15",
"lodash": "^4.17.11",
"prando": "^3.0.3"
},
"devDependencies": {
"#babel/core": "^7.0.0",
"#babel/plugin-proposal-class-properties": "^7.0.0",
"#babel/preset-env": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^8.2.3",
"babel-loader": "^8.0.0",
"babel-plugin-lodash": "^3.3.4",
"cross-env": "^5.2.0",
"eslint": "^5.6.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"husky": "^1.1.0",
"jest": "^23.6.0",
"lint-staged": "^7.3.0",
"lodash-webpack-plugin": "^0.11.5",
"prettier-eslint": "^8.8.2",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2"
},
"eslintConfig": {
"parser": "babel-eslint",
"extends": "airbnb-base",
"globals": {
"cc": true,
"ccui": true
},
"env": {
"browser": true,
"jest": true
},
"rules": {
"func-names": [
"error",
"as-needed"
],
"no-console": [
"error",
{
"allow": [
"warn",
"error",
"assert"
]
}
],
"complexity": [
"error",
5
],
"max-params": [
"error",
5
],
"max-depth": [
"error",
4
],
"max-statements": [
"error",
20
],
"max-lines-per-function": [
"error",
50
],
"max-classes-per-file": [
"error",
1
],
"max-nested-callbacks": [
"error",
3
],
"max-statements-per-line": [
"error",
{
"max": 1
}
]
}
},
"jest": {
"bail": true,
"coverageThreshold": {
"global": {
"branches": 0,
"functions": 0,
"lines": 0,
"statements": 0
}
},
"collectCoverageFrom": [
"src/**/*.js"
],
"moduleNameMapper": {
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|cur)$": "<rootDir>/src/lib/mocks/FileMock.js"
}
},
"babel": {
"presets": [
[
"#babel/preset-env",
{
"useBuiltIns": "usage",
"targets": {
"ie": "11"
}
}
]
],
"plugins": [
"#babel/plugin-proposal-class-properties"
]
},
"prettier": {
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100
}
}
webpack.config.js:
const { join } = require('path');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const { dependencies } = require('../../package.json');
const sourcePath = join(`${__dirname}/../../src`);
module.exports = {
entry: { main: './src/index.js', vendor: Object.keys(dependencies) },
optimization: { splitChunks: { name: 'vendor', minChunks: 2 } },
module: {
rules: [
{
test: /\.js$/,
include: sourcePath,
loader: 'babel-loader',
options: {
presets: [
[
'#babel/preset-env',
{
useBuiltIns: 'usage',
targets: {
ie: 11,
},
},
],
],
plugins: ['#babel/plugin-proposal-class-properties', 'lodash'],
},
},
],
},
plugins: [new LodashModuleReplacementPlugin()],
};

I think this one might help you
Difference between npm run dev and npm run production
If you try to build front-end in the server. You could try npm run build or npm run production. Try it

Related

React import problem, 'Module not found: Can't resolve' while import package wechaty

I'm new to nodejs and react. In my project, I use a package "wechaty". And it works fine when my project is a pure nodejs.
Then when I try to integrate "wechaty" with react, it failed to compile and report errors.
// Code in App.js
import { WechatyBuilder, ScanStatus, log} from "wechaty"
When I run npm start/yarn start, the error message appears
Failed to compile.
./src/App.js Module not found: Can't resolve 'wechaty' in
'D:\git\chat-client\src'
I guess it may be because there is no 'module' field in the package.json of 'wechaty', so I add that field.
"module": "./dist/esm/src/mods/mod.js",
The exact problem do disappeared. But it still cannot resolve sub modules.
Failed to compile.
./node_modules/wechaty/dist/esm/src/mods/mod.js Module not found:
Can't resolve 'wechaty-puppet/helpers' in
'D:\git\chat-client\node_modules\wechaty\dist\esm\src\mods'
Compiling... Failed to compile.
Even worse is that 'wechaty' has many dependence packages, and all the dependence packages have the same problem.
Here follows the package.json of 'wechaty':
{
"name": "wechaty",
"version": "1.0.6",
"description": "Wechaty is a RPA SDK for Chatbot Makers.",
"type": "module",
"exports": {
".": {
"import": "./dist/esm/src/mods/mod.js",
"require": "./dist/cjs/src/mods/mod.js"
},
"./impls": {
"import": "./dist/esm/src/mods/impls.js",
"require": "./dist/cjs/src/mods/impls.js"
},
"./users": {
"import": "./dist/esm/src/mods/users.js",
"require": "./dist/cjs/src/mods/uses.js"
}
},
"typesVersions": {
"*": {
"users": [
"./dist/esm/src/mods/users.d.ts"
],
"impls": [
"./dist/esm/src/mods/impls.d.ts"
]
}
},
"types": "./dist/esm/src/mods/mod.d.ts",
"engines": {
"node": ">=16",
"npm": ">=7"
},
"wechaty": {
"DEFAULT_PORT": 8080,
"DEFAULT_PROTOCOL": "io|0.0.1",
"DEFAULT_APIHOST": "api.chatie.io"
},
"scripts": {
"build": "tsc && tsc -p tsconfig.cjs.json",
"changelog": "docker run -it --rm -e CHANGELOG_GITHUB_TOKEN -v \"$(pwd)\":/usr/local/src/your-app ferrarimarco/github-changelog-generator -u wechaty -p wechaty && sed -i'.bak' /greenkeeper/d CHANGELOG.md && sed -i'.bak' /Snyk/d CHANGELOG.md && sed -i'.bak' '/An in-range update of/d' CHANGELOG.md && node --no-warnings --loader=ts-node/esm scripts/sort-contributiveness.ts < CHANGELOG.md > CHANGELOG.new.md 2>/dev/null && cat CHANGELOG.md >> CHANGELOG.new.md && mv CHANGELOG.new.md CHANGELOG.md",
"check-node-version": "check-node-version --node \">= 16\"",
"clean": "shx rm -fr dist/*",
"coverage": "nyc report --reporter=lcov",
"demo": "cross-env NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/ding-dong-bot.ts",
"dist": "npm-run-all clean build dist:commonjs",
"dist:commonjs": "jq -n \"{ type: \\\"commonjs\\\" }\" > dist/cjs/package.json",
"docs": "bash -x scripts/generate-docs.sh",
"doctor": "npm run check-node-version && node --no-warnings --loader=ts-node/esm bin/doctor.ts",
"io-client": "node --no-warnings --loader=ts-node/esm bin/io-client.ts",
"lint:es": "eslint --ignore-pattern node_modules/ --ignore-pattern fixtures/ \"{bin,examples,src,scripts,tests}/**/*.ts\"",
"lint:md": "markdownlint README.md",
"lint:sh": "bash -n bin/*.sh",
"lint:ts": "tsc --isolatedModules --noEmit",
"lint": "npm-run-all check-node-version lint:es lint:ts lint:sh lint:md",
"puppet-install": "node --no-warnings --loader=ts-node/esm bin/puppet-install.ts",
"sloc": "sloc bin examples scripts src tests --details --format cli-table --keys total,source,comment && sloc bin examples scripts src tests",
"start": "npm run demo",
"test:pack": "bash -x scripts/npm-pack-testing.sh",
"test:shell": "shellcheck bin/*.sh scripts/*.sh",
"test:unit": "cross-env NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" TAP_TIMEOUT=60 tap \"src/**/*.spec.ts\" \"tests/**/*.spec.ts\"",
"test": "npm run lint && nyc npm run test:unit && npm run sloc",
"typedoc": "bash scripts/typedoc.sh"
},
"repository": {
"type": "git",
"url": "git+https://github.com/wechaty/wechaty.git"
},
"bin": {
"wechaty-doctor": "dist/esm/bin/doctor.js",
"wechaty-io-client": "dist/esm/bin/io-client.js",
"wechaty-puppet-install": "dist/esm/bin/puppet-install.js",
"wechaty-version": "dist/esm/bin/version.js"
},
"keywords": [
"ai",
"bot",
"chatbot",
"chatie",
"conversational",
"framework",
"robot",
"rpa",
"sdk",
"wechat",
"wecom",
"wxwork",
"lark",
"TikTok",
"weixin",
"whatsapp",
"微信"
],
"author": {
"name": "Huan LI (李卓桓)",
"email": "zixia#zixia.net",
"url": "https://linkedin.com/in/zixia/"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/wechaty/wechaty/issues"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/wechaty"
},
"homepage": "https://github.com/wechaty/",
"dependencies": {
"clone-class": "^1.0.2",
"cockatiel": "^2.0.2",
"dotenv": "^10.0.0",
"json-rpc-peer": "^0.17.0",
"open-graph": "^0.2.6",
"state-switch": "^1.1.15",
"uuid": "^8.3.2",
"wechaty-puppet": "^1.0.1",
"wechaty-puppet-service": "^1.0.1",
"ws": "^8.2.3"
},
"devDependencies": {
"#chatie/eslint-config": "^1.0.3",
"#chatie/git-scripts": "^0.6.2",
"#chatie/semver": "^0.4.7",
"#chatie/tsconfig": "^1.0.2",
"#types/dotenv": "^8.2.0",
"#types/glob": "^7.2.0",
"#types/open-graph": "^0.2.2",
"#types/raven": "^2.5.4",
"#types/uuid": "^8.3.1",
"#types/ws": "^8.2.0",
"check-node-version": "^4.1.0",
"coveralls": "^3.1.1",
"glob": "^7.2.0",
"jsdoc-to-markdown": "^7.1.0",
"nyc": "^15.1.0",
"qrcode-terminal": "^0.12.0",
"raven": "^2.6.4",
"sloc": "^0.2.1",
"typed-emitter": "^1.4.0",
"typedoc": "^1.0.0-dev.4 ",
"wechaty-puppet-mock": "^1.0.1",
"wechaty-puppet-padlocal": "^0.4.2"
},
"files": [
"bin/",
"dist/",
"src/"
],
"publishConfig": {
"access": "public",
"tag": "latest"
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/wechaty"
},
"git": {
"scripts": {
"pre-push": "npx git-scripts-pre-push"
}
}
}
Here follows the ./dist/esm/src/mods/mod.js
export { WechatyBuilder, } from '../wechaty-builder.js';
export * as type from 'wechaty-puppet/types';
export * as payload from 'wechaty-puppet/payloads';
export * as helper from 'wechaty-puppet/helpers';
export * as impl from './impls.js';
export * as user from './users.js';
export * from './users.js';
export { ScanStatus, } from 'wechaty-puppet/types';
export { log, config, qrcodeValueToImageUrl, VERSION, } from '../config.js';
export { IoClient, } from '../io-client.js';
//# sourceMappingURL=mod.js.map
Here follows package.js of my own project:
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"socket.io-client": "^4.4.0",
"web-vitals": "^1.0.1",
"wechaty": "^1.0.6"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

This experimental syntax requires enabling the parser plugin: 'classPrivateMethods'

I am getting this error. There are a few similar cases that I have seen in Stackoverflow, but I checked and tried everything and the solutions didn't work.
The project itself works, it is just when I try to use pkg, I am getting the error:
> pkg src/index.js --target=latest-win-x64 --out-path ./dist --config pkg.json
:
:
> Error! This experimental syntax requires enabling the parser plugin: 'classPrivateMethods' (441:2)
E:\Proj\node_modules\node-webpmux\webp.js
All solutions basically say to add plugin-proposal-class-properties and plugin-proposal-private-methods, and specify them in the project json files (eslint, babel, package). I did that, and it doesn't help.
package.json:
"devDependencies": {
"#babel/core": "^7.14.8",
"#babel/eslint-parser": "^7.14.7",
"#babel/plugin-proposal-class-properties": "^7.14.5",
"#babel/plugin-proposal-private-methods": "^7.14.5",
"#babel/preset-env": "^7.14.8",
"#babel/preset-react": "^7.14.5",
"eslint": "^7.31.0"
},
.eslintrc.json:
{
"extends": "eslint:recommended",
"parser": "#babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"babelOptions": {
"plugins": ["#babel/plugin-proposal-class-properties",
"#babel/plugin-proposal-private-methods"]
}
},
"plugins": [
"classPrivateMethods",
"classPrivateProperties",
"babel"
],
"env": {
"node": true
},
"rules": {
"no-console": 0,
"no-unused-vars": 1,
"babel/semi": 1
}
}
.babelrc:
{
"presets": [
"#babel/preset-env",
"#babel/preset-react"
],
"plugins": [
[
"#babel/plugin-proposal-class-properties"
]
]
}
.pkg.json:
{
"name": "WA chatbot",
"version": "1.0.0",
"pkg": {
"assets": "./assets"
}
}
node version: v14.15.3
yarn: v1.22.10
Is there a solution for this?

ESLint: Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (2:9)

I am trying to use ESLint in WebStrom, but it doesn't work and displays an error:
ESLint: Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (2:9).
Here is my .eslintrc and package.json settings. What should I do for fixing the error?
package.json
{
"name": "raonair-frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"eslint-config-react-app": "^6.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"prepare": "husky install"
},
"parser": "babel-eslint",
"eslintConfig": {
"extends": [
"react-app",
"airbnb",
"plugin:flowtype/recommended"
],
"plugins": [
"flowtype"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#babel/eslint-parser": "^7.15.0",
"#babel/eslint-plugin": "^7.14.5",
"#babel/plugin-syntax-jsx": "^7.14.5",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-flowtype": "^5.9.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^7.0.1",
"prettier": "^2.3.2"
}
}
.eslintrc
{
"env": {
"browser": true,
"node": true
},
"extends": [
"airbnb",
"airbnb/hooks",
"prettier"
],
"parser": "#babel/eslint-parser",
"parserOptions": {
"sourceType": "module",
"allowImportExportEveryWhere": false,
"ecmaFeatures": {
"globalReturn": false,
"jsx": true
},
"ecmaVersion": 2020,
"babelOptions": {
"configFile": "./babel.config.js"
}
},
"plugins": [
"jsx-a11y",
"react-hooks",
"#babel/",
"flowtype",
"import"
],
"rules": {
"import/no-anonymous-default-export": "off",
"import/no-extraneous-dependencies": "off",
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling"
],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": false
}
}
],
"import/prefer-default-export": "off",
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"jsx-a11y/anchor-is-valid": "off",
"no-console": "error",
"no-unused-vars": "error",
"react/jsx-props-no-spreading": "off",
"react/react-in-jsx-scope": "off"
},
"settings": {
"import/resolver": {
"typescript": {}
},
"insert_final_newline": true
}
}
Install #babel/preset-react in dev dependencies.
Add this in .eslintrc file
...
"parser": "#babel/eslint-parser",
"parserOptions": {
...
"babelOptions": {
"presets": ["#babel/preset-react"]
},
}
...
Source: https://ffan0811.medium.com/error-debugging-this-experimental-syntax-requires-enabling-one-of-the-following-parser-plugin-s-22946599a0a4
To expand on Ceroy's answer (source):
Install dependencies needed to enable babel to properly parse jsx
yarn add #babel/preset-react -D
or
npm install --save-dev #babel/preset-react
Configure Babel
.babelrc file in the project root:
{
"presets": [
"#babel/preset-react"
]
}
Specify parser in .eslintrc.json (so your console and VSCode will use the same one) - full eslintrc shown here:
{
"parser": "#babel/eslint-parser",
"settings": {
"react": {
"version": "detect"
}
},
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"standard",
"plugin:react/jsx-runtime",
"plugin:testing-library/react",
"plugin:jest/all"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {}
}
Note: .eslintrc.json can also be created via npm init #eslint/config or by using the ESLint extension in VSCode. The init will give you more options to choose from (such as TypeScript support)
Try it out in the console: npx eslint --fix .
Check VSCode (with the ESLint extension)
Bonus:
ESLint Plugin Settings for VSCode (autofix on save, Jest aware, babel parser etc. - in global VSCode settings.json):
...
"eslint.alwaysShowStatus": true,
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"eslint.options": {
"parser": "#babel/eslint-parser"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": [
"javascript"
]
...
Full package.json:
{
"name": "okta-test",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^12.1.0",
"#testing-library/user-event": "^13.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router": "^5.2.1",
"react-router-dom": "^5.3.0",
"react-scripts": "4.0.3",
"web-vitals": "^2.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#babel/eslint-parser": "^7.15.7",
"#babel/preset-react": "^7.14.5",
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsx": "^0.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-react": "^7.26.0"
}
}
I went through this error. My problem was the version issue of eslint-config-standard.
So my solution is eslint-config-standard version downgrade 17.0.0 => 16.0.3
"eslint-config-standard": "^17.0.0" => "^16.0.3"

App built using electron-builder in electron-forge + webpack application shows blank screen

I wanted to use electron-builder in my electron-forge (webpack-template and React) app, because of the more packaging options
electron-forge app was created with
create electron-app test --template=webpack
This is my package.json
"name": "vocascan",
"productName": "vocascan",
"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\"",
"build": "electron-forge start && electron-builder --linux"
},
"keywords": [],
"build": {
"productName": "Vocascan",
"files": [
],
"linux": {
"target": [
"AppImage"
],
"category": "Development"
}
},
"license": "MIT",
"config": {
"forge": {
"packagerConfig": {},
"plugins": [
[
"#electron-forge/plugin-webpack",
{
"mainConfig": "./webpack.main.config.js",
"renderer": {
"config": "./webpack.renderer.config.js",
"entryPoints": [
{
"html": "./src/index.html",
"js": "./src/renderer.jsx",
"name": "main_window"
}
]
}
}
]
]
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.54",
"#electron-forge/maker-deb": "^6.0.0-beta.54",
"#electron-forge/maker-rpm": "^6.0.0-beta.54",
"#electron-forge/maker-squirrel": "^6.0.0-beta.54",
"#electron-forge/maker-zip": "^6.0.0-beta.54",
"#electron-forge/plugin-webpack": "6.0.0-beta.54",
"#marshallofsound/webpack-asset-relocator-loader": "^0.5.0",
"css-loader": "^4.2.1",
"electron": "10.1.5",
"node-loader": "^1.0.1",
"style-loader": "^1.2.1",
"electron-builder": "^22.9.1"
},
"dependencies": {
"#babel/core": "^7.12.3",
"#babel/preset-env": "^7.12.1",
"#babel/preset-react": "^7.12.5",
"babel-loader": "^8.1.0",
"electron-squirrel-startup": "^1.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1"
}
As you can see I added
"build": "electron-forge start && electron-builder --linux"
and
"build": {
"productName": "Vocascan",
"files": [
],
"linux": {
"target": [
"AppImage"
],
"category": "Development"
}
},
in order to make electron-builder available
the build runs just fine, but when I start the app none of my components gets shown
If someone needs the browser window code
const createWindow = () => {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
});
// and load the index.html of the app.
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
// Open the DevTools.
mainWindow.webContents.openDevTools();
};
and this is my folder structure
This template is NOT working with electron-builder.
Because this template was designed to work with the electron-forge make command. electron-builder can't work with it because it's using webpack dev server and not building a static build.
The template I linked is working with electron-builder because it's making a static build of react, the react components and the node modules you using and electron-builder can work with it.
I recommend this template: https://github.com/Levminer/create-electron-react-app

Entry module not found

ERROR in Error: Child compilation failed:
Entry module not found: Error: Can't resolve '/Users/MarkPierre/Desktop/es6-project-2019/src/index.html' in '/Users/MarkPierre/Desktop/es6-project-2019':
Error: Can't resolve '/Users/MarkPierre/Desktop/es6-project-2019/src/index.html' in '/Users/MarkPierre/Desktop/es6-project-2019'
When I run the command npm run start, I get the error message mentioned above.
I've checked the path and it's there. Any ideas?
Seems like the issue occurs with template: './starter/src/index.html'. I've removed the starter, but still the same issue. Very frustrating as this is the final part of the config :-(
babelrc file
{
"presets": [
["#babel/preset-env", {
"targets": {
"browsers": [
"last 5 versions",
"ie >= 8"
]
}
}]
]
}
package.json
{
"name": "forkify",
"version": "1.0.0",
"description": "forkify project",
"main": "index.js",
"scripts": {
"dev": "webpack: --mode development",
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --open"
},
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/core": "^7.2.2",
"#babel/preset-env": "^7.2.3",
"babel-loader": "^8.0.5",
"html-webpack-plugin": "^3.2.0",
"webpack-dev-server": "^3.1.14"
},
"dependencies": {
"#babel/polyfill": "^7.2.5"
}
}
webpack
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: ['#babel/polyfill', './starter/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'
}
}]
}
};

Resources