storefront-foundation / react-storefront

React Storefront - PWA for eCommerce. 100% offline, platform agnostic, headless, Magento 2 supported. Always Open Source, Apache-2.0 license. Join us as contributor (contributors@reactstorefront.io).
https://www.reactstorefront.io
Other
796 stars 190 forks source link

Web pack Error while running a npm start && npm run build command #170

Open gisarunpandian opened 3 years ago

gisarunpandian commented 3 years ago

Bug report

I am using MacOs 11.2.1 and I have tried to install / run and deploy react-storefront using several methods. All have failed me.

Describe the bug

  1. I used standard MacoS NodeJS v12.18.3, NPM v6.14.6. and I ran the commands from the docs:

    npm install npm start or npm run build

When I run npm start I am presented with the following error:

internal/modules/cjs/loader.js:968
  throw err;
  ^

Error: Cannot find module 'webpack'
Require stack:
- /Users/gis00217/Documents/my-doc/arun/myreact-app/next.config.js
- /Users/gis00217/Documents/my-doc/arun/myreact-app/node_modules/next/dist/next-server/server/config.js
- /Users/gis00217/Documents/my-doc/arun/myreact-app/node_modules/next/dist/next-server/server/next-server.js
- /Users/gis00217/Documents/my-doc/arun/myreact-app/node_modules/next/dist/server/next.js
- /Users/gis00217/Documents/my-doc/arun/myreact-app/server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/gis00217/Documents/my-doc/arun/myreact-app/next.config.js:1:17)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at loadConfig (/Users/gis00217/Documents/my-doc/arun/myreact-app/node_modules/next/dist/next-server/server/config.js:8:94)
    at new Server (/Users/gis00217/Documents/my-doc/arun/myreact-app/node_modules/next/dist/next-server/server/next-server.js:1:4533)
    at new DevServer (/Users/gis00217/Documents/my-doc/arun/myreact-app/node_modules/next/dist/server/next-dev-server.js:1:2964)
    at createServer (/Users/gis00217/Documents/my-doc/arun/myreact-app/node_modules/next/dist/server/next.js:2:607)
    at Object.<anonymous> (/Users/gis00217/Documents/my-doc/arun/myreact-app/server.js:14:13) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/gis00217/Documents/my-doc/arun/myreact-app/next.config.js',
    '/Users/gis00217/Documents/my-doc/arun/myreact-app/node_modules/next/dist/next-server/server/config.js',
    '/Users/gis00217/Documents/my-doc/arun/myreact-app/node_modules/next/dist/next-server/server/next-server.js',
    '/Users/gis00217/Documents/my-doc/arun/myreact-app/node_modules/next/dist/server/next.js',
    '/Users/gis00217/Documents/my-doc/arun/myreact-app/server.js'
  ]
}
[nodemon] app crashed - waiting for file changes before starting...

Expected behavior

The site is supposed to start on localhost:3000 .

Screenshots

Screenshot 2021-02-12 at 12 19 12 PM

System information

Additional context

Add any other context about the problem here.

chris--jones commented 3 years ago

I got past this by installing webpack (version 4) npm i webpack@4.46.0

NeonMando158 commented 3 years ago

Facing strange issues with react-storefront, Not really as fast as they advertise. Configuration takes a ton of time. I literally spent hours trying to fix the webpack issue.

Most notorious one Next (node:80537) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. Next (node:80537) UnhandledPromiseRejectionWarning: TypeError: Invalid value used as weak map key at WeakMap.set (<anonymous>)

boazhoch commented 3 years ago

@NeonMando158 You have to install webpack v4.