Alexey K
Alexey K

Reputation: 6723

webpack-dev-server not working Cannot find module '../lib/polyfills'

I moved my project to another computer, ran npm install. Project works fine except webpack-dev-server, it throws error

module.js:544
throw err;
^

Error: Cannot find module '../lib/polyfills'
    at Function.Module._resolveFilename (module.js:542:15)
    at Function.Module._load (module.js:472:25)
    at Module.require (module.js:585:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/project/node_modules/.bin/webpack-dev-server:6:1)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)
    at Function.Module._load (module.js:495:3)

What is it missing ?

Upvotes: 16

Views: 14129

Answers (3)

Minimul
Minimul

Reputation: 4205

I bumped my webpack-dev-server version in package.json up one dot release and ran yarn and that fixed it.

For example in package.json:

   },
   "devDependencies": {
-    "webpack-dev-server": "2.11.2"
+    "webpack-dev-server": "2.11.3"
   }
 }

Then ran yarn and the problem was fixed.

Upvotes: 0

Kabir Sarin
Kabir Sarin

Reputation: 18526

The fix: rm -rf node_modules && npm install

Because..... who knows why /shrug

Upvotes: 45

oooyaya
oooyaya

Reputation: 1783

I had this exact issue and fixed it doing the following.

Running webpack-dev-server gave the error you pasted.

I thought it may have been a configuration issue, so I tried node_modules/.bin/webpack-dev-server to fix the configuration via the CLI.

Doing this, I was given the same error.

The file inside of .bin existed but something was clearly wrong. I suspect it's because I seeded this project by copying from another one and perhaps references normally set as part of npm install weren't set on the copy, so they were still pointing to the source of my copy.

Regardless, run npm install --save-dev webpack-dev-server again and try. Fixed my issue both in running webpack-dev-server and the CLI even though they were already installed. Perhaps just installed improperly.

Upvotes: 19

Related Questions