codesbiome / electron-react-webpack-typescript-2024

Electron React Webpack Typescript Boilerplate with Custom Window and Titlebar Menus.
MIT License
356 stars 78 forks source link

Module not found: Error: Can't resolve './src' in 'electron-react-webpack-typescript-2021' #8

Closed raphael10-collab closed 3 years ago

raphael10-collab commented 3 years ago

Running npx webpack (https://webpack.js.org/guides/getting-started/#creating-a-bundle) I get this error:

(base) marco@pc01:~/webMatters/electronMatters/electron-react-webpack-typescript-2021$ npx webpack
Module not found: Error: Can't resolve './src' in '/home/marco/webMatters/electronMatters/electron-react-webpack-
typescript-2021'

Also modifying the webpack.main.js resolve path:

resolve: {
  extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
 //alias: require('./webpack.aliases'),
  modules: [path.resolve(__dirname, 'src'), 'node_modules'],
},

doesn't resolve the problem: Module not found: Error: Can't resolve './src' in '/home/marco/webMatters/electronMatters/Ipfs-Webpack'

codesbiome commented 3 years ago

Command npx webpack requires an entry file to be present, for example ./src/index.js In this project we aren't using index.js file as entry point, so you can give this command a try @raphael10-collab

npx webpack --entry ./src/main.ts


Not really sure if that'd work without any error, because the command npx wepback would still require whole webpack configuration file webpack.config.js to be available with required configuration, loaders, entrypoints etc to compile the assets used in this project.

raphael10-collab commented 3 years ago
(base) marco@pc01:~/webMatters/electronMatters/electron-react-webpack-typescript-2021$ npx webpack --entry ./src/main.ts
Need to install the following packages:
  webpack
Ok to proceed? (y) y
CLI for webpack must be installed.
  webpack-cli (https://github.com/webpack/webpack-cli)

We will use "yarn" to install the CLI via "yarn add -D webpack-cli".
Do you want to install 'webpack-cli' (yes/no): yes
Installing 'webpack-cli' (running 'yarn add -D webpack-cli')...
yarn add v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.3.1: The platform "linux" is incompatible with this module.
info "fsevents@2.3.1" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ webpack-cli@4.5.0
info All dependencies
└─ webpack-cli@4.5.0
Done in 10.63s.
Error: Cannot find module 'webpack-cli/package.json'
Require stack:
- /home/marco/.npm/_npx/89d6e678e21f2dae/node_modules/webpack/bin/webpack.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1030:15)
    at Function.resolve (internal/modules/cjs/helpers.js:81:19)
    at runCli (/home/marco/.npm/_npx/89d6e678e21f2dae/node_modules/webpack/bin/webpack.js:50:26)
    at /home/marco/.npm/_npx/89d6e678e21f2dae/node_modules/webpack/bin/webpack.js:139:5
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/marco/.npm/_npx/89d6e678e21f2dae/node_modules/webpack/bin/webpack.js'
  ]
}
npm ERR! code 1
npm ERR! path /home/marco/webMatters/electronMatters/electron-react-webpack-typescript-2021
npm ERR! command failed
npm ERR! command sh -c webpack "--entry" "./src/main.ts"

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/marco/.npm/_logs/2021-02-10T08_06_31_503Z-debug.log
codesbiome commented 3 years ago
Error: Cannot find module 'webpack-cli/package.json'

This is some strange output @raphael10-collab, could you explain a little about what you're trying to perform with npx webpack in the ERWT boilerplate?

JSLNO commented 3 years ago

any update on how to fix this?

codesbiome commented 3 years ago

@JSLNO is there any Testing Repository which is related to this issue? It'd be helpful to have a testing repository for reproducing the issue mentioned in here.