1

I installed puppeteer using npm, then when tried to compile it, there are errors:

This dependency was not found:

* ws in ./node_modules/puppeteer/lib/WebSocketTransport.js

To install it, you can run: npm install --save ws


These relative modules were not found:

* ./types/other in ./node_modules/puppeteer/node_modules/mime/index.js
* ./types/standard in ./node_modules/puppeteer/node_modules/mime/index.js 

About ws: I tried to install ws again using npm install --save ws but still the same.

About ./types/other and .types/standard, I tried to edit the file node_modules/puppeteer/node_modules/mime/index.js and added .json at the end of file name in require. I know it is not correct to edit file from vendor folder, but I don't know how to fix it in correct way.

I tried solutions from here: https://github.com/GoogleChrome/puppeteer/issues/2754#issuecomment-403321142

But still no luck, or I don't know if I understand it correctly.

Here is my package.json:

{
  "jest": {
    "moduleFileExtensions": [
      "json",
      "vue",
      "js"
    ]
  },
  "private": true,
  "scripts": {
     ...
  },
  "devDependencies": {
    "axios": "^0.17",
    "bootstrap": "^4.1.3",
    "cross-env": "^5.2.0",
    "jquery": "^3.2",
    "laravel-mix": "^2.1.14",
    "lodash": "^4.17.11",
    "popper.js": "^1.14.4",
    "postcss-css-variables": "^0.9.0",
    "vue": "^2.5.17"
  },
  "dependencies": {
    "ajv": "^6.0.0",
    "imagemin": "^5.0.0",
    "npm": "^5.10.0",
    "puppeteer": "^1.14.0",
    "ws": "^6.2.1"
  }
}

I think adding jest there doesn't make sense since I don't have jest installed, But I don't know now how to fix it.

rmondesilva
  • 1,732
  • 3
  • 17
  • 29
  • Possible duplicate of [How to run Puppeteer code in any web browser?](https://stackoverflow.com/questions/54647694/how-to-run-puppeteer-code-in-any-web-browser) – Md. Abu Taher Apr 04 '19 at 01:11
  • It's not quite same but it's highly related problem. Webpack cannot bundle puppeteer yet but you can use the other solution provided. Check the linked answer. – Md. Abu Taher Apr 04 '19 at 01:14

1 Answers1

0

so i had the same problem when trying to use puppeteer but there was a problem in the dependencies of puppeteer itself. i was unable to find a solution but i found another way to still use pupeteer threw another module.first run these in the command line

npm install --save apify

then also get its cli

npm install -g apify-cli

then run

apify create my-hello-world

and chose the option that uses puppeteer, it will give a ready made example and you can start from there using puppeteer as you would normally , it also gives u more options like local storage and running the code in the cloud, but these are not a must you could use it as a replacement for puppeteer

for more info go to here this is a link to the basic apify module with examples and commands

there is also an offical website in case you want use it in more advanced web-scraping getting started with apify

karim samir
  • 99
  • 1
  • 5