question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module not found: Error: Can't resolve 'ws'

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 2.1.1
  • Platform / OS version: Windows 10
  • URLs (if applicable):
  • Node.js version: v13.9.0

What steps will reproduce the problem?

  • ng new test
  • cd test
  • npm install puppeteer

Please include code that reproduces the issue.


import * as puppeteer from 'puppeteer';

 GeneraPdf() {
    (async () => {
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
      await page.goto('https://google.com');
      await page.pdf({path: 'hn.pdf', format: 'A4'});
    
      await browser.close();
    })();
  }

What is the expected result?

Compile

What happens instead?

PS C:\Users\Giacomo\Documents\Progetti\Angular\Testpuppeteer> ng serve

chunk {main} main.js, main.js.map (main) 13.7 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 140 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 10.1 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.75 MB [initial] [rendered]
Date: 2020-02-28T11:06:47.573Z - Hash: fed516f7933ffc2f9d0a - Time: 5671ms

ERROR in ./node_modules/puppeteer/lib/WebSocketTransport.js
Module not found: Error: Can't resolve 'ws' in 'C:\Users\X\Documents\Progetti\Angular\Testpuppeteer\node_modules\puppeteer\lib'
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
navarrojandgcommented, Apr 29, 2020

So i was able to fix this issue by installing puppeteer-core and then in my webpack config adding

externals: {
  'puppeteer-core': 'require("puppeteer-core")'
}

so you would need to pass in the chrome executable path in order for launch / connect to work now

0reactions
pourya-zlncommented, Nov 21, 2022

Works for me! thanks man

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found error can't resolve 'ws' in puppeteer-core/lib
I am getting the same error while compiling. ERROR in ./node_modules/puppeteer/lib/WebSocketTransport.js Module not found: Error: Can't resolve ...
Read more >
Can't run puppeteer in react app, Module not found
Simple answer : You can't run puppeteer in react app. React is a client side framework. which means it runs in browser.
Read more >
module-not-found - Next.js
A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies;...
Read more >
Module not found: Can't resolve 'zlib' error [Solved] | bobbyhadz
The error "Module not found: Can't resolve 'zlib'" most commonly occurs when you import a Node.js specific function in your frontend (e.g. React.js)...
Read more >
A Fresh Create React App But always compiling with Error
ERROR in Module not found: Error: Can't resolve ... #2/frontend/node_modules/webpack-dev-server/client/index.js?protocol=ws%3A&hostname= ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found