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.

[Bug]: puppeteer-core trying to load package.json "Cannot find package directory"

See original GitHub issue

Bug description

Steps to reproduce the problem:

  1. create project with puppeteer-core dependency
  2. 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:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
imtigercommented, Sep 5, 2022
image

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.

1reaction
OrKoNcommented, Sep 3, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

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