Module not found: Can't resolve 'apollo-client' - reactjs

While migrating from apollo-boost to #apollo/client 3.x lib. for reactjs-graphql application facing this issue.
Failed to compile.
./node_modules/#apollo/react-hooks/lib/react-hooks.esm.js
Module not found: Can't resolve 'apollo-client' in 'C:\geospat\node_modules\#apollo\react-hooks\lib'
For reference used apollo-boost-migration and apollo-client-3-migration documents.
Below is the new package.json
{
"name": "gui",
"version": "0.1.0",
"private": true,
"dependencies": {
"#apollo/client": "^3.3.21",
"graphql": "14.5.8",
"#material-ui/core": "^4.11.0",
"leaflet": "1.5.1",
"luxon": "^1.24.1",
"moment": "2.24.0",
"i18next": "17.0.12",
"i18next-xhr-backend": "3.1.2",
"#types/jest": "24.0.17",
"#types/leaflet": "1.5.1",
"#types/luxon": "^1.24.0",
"#types/node": "12.7.1",
"#types/react": "16.9.1",
"#types/react-dom": "16.8.5",
"#types/react-leaflet": "2.4.0",
"#types/react-loader-spinner": "^3.1.0",
"#types/recharts": "^1.8.16",
"classnames": "2.2.6",
"jest-sonar-reporter": "2.0.0",
"node-sass": "4.12.0",
"normalize.css": "8.0.1",
"numeral": "2.0.6",
"ramda": "0.26.1",
"react": "16.12.0",
"react-apollo": "3.1.3",
"react-dom": "16.12.0",
"react-i18next": "10.12.2",
"react-idle-timer": "^4.5.2",
"react-leaflet": "2.4.0",
"react-loader-spinner": "^3.1.14",
"react-redux": "7.1.0",
"react-router-dom": "5.0.1",
"react-scripts": "3.3.0",
"redux": "4.0.4",
"typescript": "3.5.3",
"use-query-params": "0.4.5"
},
"devDependencies": {
"#types/classnames": "2.2.9",
"#types/debug": "4.1.5",
"#types/enzyme": "3.10.3",
"#types/enzyme-adapter-react-16": "1.0.5",
"#types/enzyme-to-json": "1.5.3",
"#types/ramda": "0.26.29",
"#types/react-redux": "7.1.1",
"#types/react-router-dom": "4.3.5",
"#types/redux-mock-store": "1.0.1",
"enzyme": "3.10.0",
"enzyme-adapter-react-16": "1.14.0",
"enzyme-to-json": "3.4.0",
"mock-apollo-client": "1.1.0",
"react-dates": "21.0.1",
"react-leaflet-vectorgrid": "2.2.1",
"recharts": "1.7.1",
"redux-devtools-extension": "2.13.8",
"redux-mock-store": "1.5.3",
"waait": "1.0.5"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"collectCoverageFrom": [
"!src/**/*.snap",
"src/components/**/*.{ts,tsx}",
"src/configuration/**/*"
],
"transformIgnorePatterns": []
},
"jestSonar": {
"reportPath": "coverage",
"reportFile": "jest-sonar-report.xml",
"indent": 4
}
}
Tried deleting old node_modules directory and then ran npm i command but the same error was shown on the console.
What is missed here?

When migrating to #apollo/client 3.x from earlier version or apollo-boost, all other apollo related libraries needs to be removed and their references in code ( mostly import statements ) needs to be replaced by '#apollo/client'.
In the above package.json most of the apollo packages were removed except "react-apollo".
Once that package is removed, the error mentioned above went away or rather replaced by new errors.
But it's just replacing the erring import statements with the one for '#apollo/client'.

npm i #apollo/client and then using #apollo/client in import statement

Related

Module not found: Can't resolve "NPM LINKED MODULE" when using npm-link

I'm working on a TypeScript React application which heavily relies on a private NPM package. I can successfully link the NPM package, but after doing so I get the error <pre>/src/components/xxxx/xxxx/xxxxx/xxxxHoc.tsx Module not found: Can&apos;t resolve &apos;#CompanyName/Company-package&apos; in &apos;/home/liam/CompanyName/Company-product/src/components/xxxx/xxxx/xxxxx&apos;</pre>
riddle all over the application where the npm package is imported. NPM isntalling this package traditionally does works as intended but I need to be able to locally test the package.
Typically when I npm-link the package it gets removed from package.json, I'm not sure if thats how it's supposed to work? would love some insight if possible
I was successfully able to npm-link this package to a laravel applicaiton, but linking it to this particular react app does not work.
Main projects package.json file
{
"name": "Company-product",
"version": "0.1.0",
"private": true,
"dependencies": {
"#aws-sdk/client-dynamodb": "^3.37.0",
"#aws-sdk/util-dynamodb": "^3.37.0",
"#elastic/apm-rum": "^5.9.1",
"#elastic/apm-rum-react": "^1.3.1",
"#fingerprintjs/fingerprintjs": "^3.3.0",
"#fortawesome/fontawesome-svg-core": "^1.2.36",
"#fortawesome/free-regular-svg-icons": "^5.15.4",
"#fortawesome/free-solid-svg-icons": "^5.15.4",
"#fortawesome/react-fontawesome": "^0.1.16",
"#CompanyName/NPM-LINKED-MODULE": "^2.10.0",
"#testing-library/jest-dom": "^5.14.1",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^12.8.3",
"#types/fingerprintjs": "^0.5.28",
"#types/jest": "^26.0.24",
"#types/js-cookie": "^2.2.7",
"#types/node": "^12.20.33",
"#types/react": "^16.14.17",
"#types/react-csv": "^1.1.2",
"#types/react-dom": "^16.9.14",
"#types/react-router-dom": "^5.3.1",
"#types/react-select": "^3.0.28",
"aws-sdk": "^2.1012.0",
"bootstrap": "^4.6.0",
"deepmerge": "^4.2.2",
"formik": "^2.2.9",
"highcharts": "^8.2.2",
"highcharts-react-official": "^3.1.0",
"husky": "^4.3.8",
"ismobilejs": "^1.1.1",
"js-cookie": "^2.2.1",
"jwt-decode": "^3.1.2",
"luxon": "^1.28.0",
"mobx": "^6.3.5",
"mobx-react-lite": "^3.2.1",
"moment": "^2.29.1",
"moment-timezone": "^0.5.33",
"node-sass": "^4.14",
"nvm": "^0.0.4",
"react": "^17.0.2",
"react-bootstrap": "^1.6.4",
"react-csv": "^2.0.3",
"react-dom": "^17.0.2",
"react-map-gl": "^6.1.17",
"react-router-dom": "^5.3.0",
"react-scripts": "4.0.1",
"react-select": "^3.1.1",
"react-table": "^7.7.0",
"react-toastify": "^6.2.0",
"typescript": "^4.4.4",
"urijs": "^1.19.7",
"utility-types": "^3.10.0",
"web-vitals": "^0.2.4",
"worker-loader": "^3.0.8",
"yup": "^0.32.11"
},
"husky": {
"hooks": {
"pre-commit": "sh ./hooks/pre-commit"
}
},
"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": {
"#types/luxon": "^1.27.1",
"#types/react-map-gl": "^5.2.11",
"#types/react-table": "^7.7.7",
"#types/urijs": "^1.19.17"
}
The linked NPM package package.json file
{
"name": "#CompanyName/linked-module",
"version": "2.10.0",
"description": "Company Package",
"author": "Company",
"license": "MIT",
"repository": "CompanyName/company-package",
"main": "dist/bundle.js",
"types": "dist/index.d.ts",
"dependencies": {
"#types/jquery": "^3.3.33",
"#types/node": "^12.20.33",
"#types/urijs": "^1.19.6",
"axios": "^0.21.4",
"deepmerge": "^4.2.2",
"dotenv": "^8.2.0",
"highcharts": "^8.2.2",
"ismobilejs": "^1.1.1",
"moment": "^2.24.0",
"urijs": "^1.19.7"
},
"devDependencies": {
"ts-loader": "^6.2.1",
"typescript": "^3.8.3",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11"
}
}
Thanks for any awnsers

Bootstrap for ReactJS

I installed a npm package bootstrap#4.1.0 for ReactJS portfolio App , but getting an error that non-JS module files deprecated.
So should I stop thinking of using Bootstrap for React app?
crbug/1173575, non-JS module files deprecated.
This is my package.json:
"name": "react-scripts",
"version": "4.0.3",
"description": "Configuration and scripts for Create React App.",
"repository": {
"type": "git",
"url": "https://github.com/facebook/create-react-app.git",
"directory": "packages/react-scripts"
},
"license": "MIT",
"engines": {
"node": "^10.12.0 || >=12.0.0"
},
"bugs": {
"url": "https://github.com/facebook/create-react-app/issues"
},
"files": [
"bin",
"config",
"lib",
"scripts",
"template",
"template-typescript",
"utils"
],
"bin": {
"react-scripts": "./bin/react-scripts.js"
},
"types": "./lib/react-app.d.ts",
"dependencies": {
"#babel/core": "7.12.3",
"#pmmmwh/react-refresh-webpack-plugin": "0.4.3",
"#svgr/webpack": "5.5.0",
"#typescript-eslint/eslint-plugin": "^4.5.0",
"#typescript-eslint/parser": "^4.5.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.7",
"babel-preset-react-app": "^10.0.0",
"bfj": "^7.0.2",
"camelcase": "^6.1.0",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"css-loader": "4.3.0",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"eslint": "^7.11.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^3.9.2",
"eslint-webpack-plugin": "^2.5.2",
"file-loader": "6.1.1",
"fs-extra": "^9.0.1",
"html-webpack-plugin": "4.5.0",
"identity-obj-proxy": "3.0.0",
"jest": "26.6.0",
"jest-circus": "26.6.0",
"jest-resolve": "26.6.0",
"jest-watch-typeahead": "0.6.1",
"mini-css-extract-plugin": "0.11.3",
"optimize-css-assets-webpack-plugin": "5.0.4",
"pnp-webpack-plugin": "1.6.4",
"postcss-flexbugs-fixes": "4.2.1",
"postcss-loader": "3.0.0",
"postcss-normalize": "8.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "5.0.2",
"prompts": "2.4.0",
"react-app-polyfill": "^2.0.0",
"react-dev-utils": "^11.0.3",
"react-refresh": "^0.8.3",
"resolve": "1.18.1",
"resolve-url-loader": "^3.1.2",
"sass-loader": "^10.0.5",
"semver": "7.3.2",
"style-loader": "1.3.0",
"terser-webpack-plugin": "4.2.3",
"ts-pnp": "1.2.0",
"url-loader": "4.1.1",
"webpack": "4.44.2",
"webpack-dev-server": "3.11.1",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "5.1.4"
},
"devDependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"optionalDependencies": {
"fsevents": "^2.1.3"
},
"peerDependencies": {
"react": ">= 16",
"typescript": "^3.2.1 || ^4"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"gitHead": "f92c37a6e6636ed1650ffd976c6881f59b1be803"
}
This is my webpack.config.js:
``` {
test: cssRegex,
exclude: cssModuleRegex,
use: getStyleLoaders({
importLoaders: 1,
modules:true,
sourceMap: isEnvProduction
? shouldUseSourceMap
: isEnvDevelopment,
}),
// Don't consider CSS imports dead code even if the
// containing package claims to have no side effects.
// Remove this when webpack adds a warning or an error for this.
// See https://github.com/webpack/webpack/issues/6571
sideEffects: true,
},```
Hope I have shared it correctly:)

React App Not Loading into The Packaged Electron App

I'm trying to package my react app with electron 8. I've followed the instructions in this article and made the necessary changes to suit my code:
https://medium.com/#johndyer24/building-a-production-electron-create-react-app-application-with-shared-code-using-electron-builder-c1f70f0e2649
Here's what I'm currently seeing after packaging.
Here's my package.json
{
"homepage": "./",
"name": "Asset_Viewer",
"version": "0.1.0",
"private": true,
"dependencies": {
"#babel/core": "7.9.0",
"#svgr/webpack": "4.3.3",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"#typescript-eslint/eslint-plugin": "^2.10.0",
"#typescript-eslint/parser": "^2.10.0",
"babel-eslint": "10.1.0",
"babel-jest": "^24.9.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.6",
"babel-preset-react-app": "^9.1.2",
"bootstrap": "^4.5.2",
"camelcase": "^5.3.1",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"concurrently": "^5.2.0",
"cross-env": "^7.0.2",
"css-loader": "3.4.2",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"electron-is-dev": "^1.2.0",
"eslint": "^6.6.0",
"eslint-config-react-app": "^5.2.1",
"eslint-loader": "3.0.3",
"eslint-plugin-flowtype": "4.6.0",
"eslint-plugin-import": "2.20.1",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-react-hooks": "^1.6.1",
"file-loader": "4.3.0",
"fs-extra": "^8.1.0",
"html-webpack-plugin": "4.0.0-beta.11",
"identity-obj-proxy": "3.0.0",
"jest": "24.9.0",
"jest-environment-jsdom-fourteen": "1.0.1",
"jest-resolve": "24.9.0",
"jest-watch-typeahead": "0.4.2",
"mini-css-extract-plugin": "0.9.0",
"node-sass": "^4.14.1",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pnp-webpack-plugin": "1.6.4",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-normalize": "8.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.1",
"react": "^16.13.1",
"react-app-polyfill": "^1.0.6",
"react-bootstrap": "^1.3.0",
"react-dev-utils": "^10.2.1",
"react-dom": "^16.13.1",
"react-icons": "^3.10.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.1",
"resolve": "1.15.0",
"resolve-url-loader": "3.1.1",
"sass-loader": "8.0.2",
"semver": "6.3.0",
"shelljs": "^0.8.4",
"sqlite3": "^5.0.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "2.3.5",
"ts-pnp": "1.1.6",
"url-loader": "2.3.0",
"wait-on": "^5.0.0",
"webpack": "4.42.0",
"webpack-dev-server": "3.10.3",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "4.3.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"build-electron": "mkdir build\\src > nul & robocopy src\\shared build\\src\\shared /s > nul & robocopy electron build\\electron /s > nul || exit 0",
"electron-dev": "concurrently \"cross-env BROWSER=none npm run start\" \"wait-on http://localhost:3000 && electron .\"",
"eject": "react-scripts eject",
"electron-pack": "electron-builder -c.extraMetadata.main=build/electron.js",
"preelectron-pack": "npm run build"
},
"build": {
"appId": "com.icom.icomuav",
"files": [
"build/**/*",
"node_modules/**/*"
],
"directories": {
"buildResources": "assets"
}
},
"main": "public/electron.js",
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"style-loader": "^1.2.1",
"electron": "^8.2.5",
"electron-builder": "^22.6.0"
},
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [
"<rootDir>/src/setupTests.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
},
"babel": {
"presets": [
"react-app"
]
}
}
Basically this are the order which I run the scripts to package the whole thing.
build
build-electron
electron-pack
Any help would be appreciated. Thanks!
I know that I'm late to this, but I spent days tracking this issue down.
I ran npm run build first to package my react application so that i would actually have a build folder.
In my case, after using electron-forge to package my application, inside index.html all of my local imports to my .js files were missing the '.' before "/static/js/etc.js".
example:
example 2:
once changing it to the correct one as shown, it loaded everything just fine:
I really hope this helps someone.
I would suggest you to log the current route to the console, so you can see what page is loaded when you open both the development and the production build.
It might be caused by the router. In your project you probably have only 1 real HTML page - index.html, so make sure it loads /index.html and not /index.html/# (hash mode) or something.
Also try to add this event listener in your main process:
// Replace YOUR_WINDOW and modify the line that loads the URL
// (the same way you load URL when the window is created)
YOUR_WINDOW.webContents.on('did-fail-load', () => {
if (process.env.NODE_ENV === 'production') {
YOUR_WINDOW.loadURL('app://./index.html')
}
})
This can be fixed with chrome settings.
Please try to uncheck maps settings in Developer Tools Settings, and then refresh chrome.
uncheck Enable JavaScript source maps
uncheck Enable CSS source maps

How to solve parsing error when export type in CRA typescript environment

I build application with CRA typescript template.
When I used this code, there is parsing error.
export type { BaseModalProps } from "./BaseModalProps"
Parsing error: Declaration or statement expected
These are part of my package.json and .eslintrc
// package.json
"dependencies": {
"#craco/craco": "^5.6.4",
"#material-ui/core": "^4.11.0",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"#types/jest": "^24.0.0",
"#types/node": "^12.0.0",
"#types/react": "^16.9.0",
"#types/react-dom": "^16.9.0",
"axios": "^0.20.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-facebook-login": "^4.1.1",
"react-google-login": "^5.1.21",
"react-hook-form": "^6.8.1",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"styled-components": "^5.1.1",
"styled-reset": "^4.2.1"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#types/react-facebook-login": "^4.1.2",
"#types/react-redux": "^7.1.9",
"#types/react-router-dom": "^5.1.5",
"#types/redux-logger": "^3.0.8",
"#types/styled-components": "^5.1.2",
"#typescript-eslint/eslint-plugin": "^4.1.0",
"#typescript-eslint/parser": "^4.1.0",
"craco-alias": "^2.1.1",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.0.8",
"husky": ">=4",
"lint-staged": ">=10",
"prettier": "^2.1.1",
"typescript": "^4.0.2"
},
// .eslintrc
"env": {
"browser": true,
"es2020": true
},
"parser": "#typescript-eslint/parser",
"plugins": ["#typescript-eslint", "react"],
"extends": [
"plugin:react/recommended",
"airbnb",
"prettier/react",
"plugin:prettier/recommended",
"plugin:#typescript-eslint/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"tsx": true,
"ts": true,
"d.ts": true
},
"ecmaVersion": 11,
"sourceType": "module"
},
how can I solve this?
I'm not exactly sure how to fix so I disabled and enabled.
/* eslint-disable */
export type { BaseModalProps } from "./BaseModalProps"
/* eslint-enable */
ALTERNATIVE:
In my research, a lot of people were able to fix by reloading their environment. We can do this in VS Code by:
cmd+shift+p (ctrl+shift+p)
>Reload Window
enter
This will reload the VS Code window you are on as if you just opened the project.

Noob question: How can I turn my create-react-app into a standalone offline video game .exe program that does not require anything else to run?

I'm making a video game with create-react-app and typescript. I've tried distributing with electron but it is such a mess and I'm totally lost. I've put so much effort on this game that I really need to make a proper .exe build for, and now that I want to make a build I'm totally lost and helpless.
Also, there are some stuff I need to be able to do:
I need to be able to change resolution from the .tsx files
I need to be able to toggle fullscreen from the .tsx files
I need to be able to load assets located in /src
Everything needs to run locally and even offline
I need my public folder to be trully accessible and moddable for the end user
I can't find anything that I can properly understand and execute after several weeks of trying.
Please help.
nb: I did this eject thing once to fix electron which can't be undone.
directories and how things are structured
My package.json file:
{
"name": "<the name>",
"author": "<my name>",
"version": "0.1.0",
"description": "<the description>",
"private": true,
"dependencies": {
"#babel/core": "7.9.0",
"#electron/typescript-definitions": "^8.7.4",
"#kennethormandy/react-fittext": "^0.6.0",
"#material-ui/icons": "^4.9.1",
"#react-native-community/async-storage": "^1.10.0",
"#svgr/webpack": "4.3.3",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"#typegoose/typegoose": "^7.0.0",
"#types/jest": "^24.9.1",
"#types/mongoose": "^5.7.14",
"#types/node": "^12.12.37",
"#types/react": "^16.9.34",
"#types/react-beautiful-dnd": "^12.1.2",
"#types/react-dom": "^16.9.7",
"#types/socket.io-client": "^1.4.32",
"#types/tweenjs": "^1.0.0",
"#typescript-eslint/eslint-plugin": "^2.10.0",
"#typescript-eslint/parser": "^2.10.0",
"alm": "^2.39.1",
"babel-eslint": "10.1.0",
"babel-jest": "^24.9.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.6",
"babel-preset-react-app": "^9.1.2",
"camelcase": "^5.3.1",
"case-sensitive-paths-webpack-plugin": "2.3.0",
"css-loader": "3.4.2",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"electron-browser-storage": "^1.0.6",
"electron-simple-window-manager": "^1.1.1",
"electron-store": "^5.1.1",
"eslint": "^6.6.0",
"eslint-config-react-app": "^5.2.1",
"eslint-loader": "3.0.3",
"eslint-plugin-flowtype": "4.6.0",
"eslint-plugin-import": "2.20.1",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-react-hooks": "^1.6.1",
"file-loader": "4.3.0",
"fs-extra": "^8.1.0",
"howler": "^2.2.0",
"html-webpack-plugin": "4.0.0-beta.11",
"identity-obj-proxy": "3.0.0",
"jest": "24.9.0",
"jest-environment-jsdom-fourteen": "1.0.1",
"jest-resolve": "24.9.0",
"jest-watch-typeahead": "0.4.2",
"mini-css-extract-plugin": "0.9.0",
"mongoose": "^5.9.11",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pnp-webpack-plugin": "1.6.4",
"popmotion": "^8.7.3",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-normalize": "8.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.1",
"react": "^16.13.1",
"react-app-polyfill": "^1.0.6",
"react-aspect-ratio": "^1.0.42",
"react-beautiful-dnd": "^13.0.0",
"react-dev-utils": "^10.2.1",
"react-dnd": "^10.0.2",
"react-dnd-html5-backend": "^10.0.2",
"react-dom": "^16.13.1",
"react-draggable": "^4.3.1",
"react-fittext": "^1.0.0",
"react-icons": "^3.10.0",
"react-image-tint": "^1.0.2",
"react-native-easy-dnd": "^1.0.2",
"react-responsive-spritesheet": "^2.3.9",
"react-textfit": "^1.1.0",
"react-z-index": "^3.0.0",
"resolve": "1.15.0",
"resolve-url-loader": "3.1.1",
"sass-loader": "8.0.2",
"semver": "6.3.0",
"socket.io-client": "^2.3.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "2.3.5",
"ts-pnp": "1.1.6",
"tweenjs": "^1.0.2",
"typescript-react-draggable": "^1.0.0",
"url-loader": "2.3.0",
"webpack": "4.42.0",
"webpack-dev-server": "3.10.3",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "4.3.1",
"xml-js": "^1.6.11"
},
"scripts": {
"pack": "electron-builder build --dir",
"dist": "npm run build && electron-builder build",
"postinstall": "install-app-deps",
"start": "nf start -p 3000",
"build": "node scripts/build.js",
"test": "node scripts/test.js",
"eject": "node scripts/eject.js",
"electron": "electron .",
"electron-start": "node src/electron-wait-react.js",
"react-start": "set BROWSER=nul && node scripts/start.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#types/express": "^4.17.6",
"#types/howler": "^2.1.2",
"#types/socket.io": "^2.1.4",
"electron-builder": "^22.6.0",
"express": "^4.17.1",
"foreman": "^3.0.1",
"node-sass": "^4.14.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-native-web": "0.11.2",
"socketio": "^1.0.0",
"typescript": "^3.8.3"
},
"homepage": "./",
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [
"C:\\Users\\mr003\\Documents\\programmation\\ZwangReact\\zwang\\src"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
},
"babel": {
"presets": [
"react-app"
]
}
}

Resources