[Bug]: puppeteer-core trying to load package.json "Cannot find package directory"
See original GitHub issueBug description
Steps to reproduce the problem:
- create project with puppeteer-core dependency
- build app and start without package.json in folder
why does this error occur? I have debugged the app and for reasons unknown to me, puppeteer tried to load a package.json. It can not be that you should push the package.json with a deployment, right?
if i build and run the app locally it works, but only because the package.json exists.
Puppeteer version
16.2.0
Node.js version
16.10.0
npm version
7.24.0
What operating system are you seeing the problem on?
Linux
Relevant log output
Error: Cannot find package directory
at exports.getPackageDirectory (/app/main.js:2:1175154)
at exports.initializePuppeteer (/app/main.js:2:1115914)
at Object.2056 (/app/main.js:2:1172454)
at __webpack_require__ (/app/main.js:2:1730339)
at Object.7157 (/app/main.js:2:578353)
at __webpack_require__ (/app/main.js:2:1730339)
at Object.5052 (/app/main.js:2:575175)
at __webpack_require__ (/app/main.js:2:1730339)
at Object.6828 (/app/main.js:2:574225)
at __webpack_require__ (/app/main.js:2:1730339)
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
Cannot find module 'puppeteer' - node.js - Stack Overflow
The puppeteer module was put in a Layer (in the folder structure mentioned in the question) and require('puppeteer') now works.
Read more >Troubleshooting - Puppeteer
Cannot find module 'puppeteer-core/internal/. ... To fix, you'll need to install the missing dependencies and the latest Chromium package in your Dockerfile ...
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
To fix the error, you need to install the package that is absent in your project directory – npm install package-name or yarn...
Read more >Puppeteer - npm
Puppeteer is a Node.js library which provides a high-level API to control Chrome/Chromium over the DevTools Protocol.
Read more >Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module" after installing something globally (with -g)? Well, this video shows you how to fix global package /module ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this is my package.json dependencies,i use puppeteer not puppeteer-core.
https://github.com/puppeteer/puppeteer/blob/eb6cea4f575467beca9a952ddf3045b7a38c44d5/src/util/getPackageDirectory.ts
this method throws the exception.
Puppeteer uses package.json to locate the Puppeteer’s installation directory because it’s where the downloaded browser binaries are stored by Puppeteer. If this functionality is not required for you, you can use the
puppeteer-core
package.