Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when npm install, get an error #27

Closed
SamWeichangyue opened this issue Apr 8, 2021 · 10 comments
Closed

when npm install, get an error #27

SamWeichangyue opened this issue Apr 8, 2021 · 10 comments

Comments

@SamWeichangyue
Copy link

platform: M1 Mac Mini
Macos: 11.2.3
browser: google chrome arm64
node version: v15.12.0
npm version: 7.6.3

desc: when npm i , then an error appear , like below:

command sh -c node ./scripts/findChrome.js
npm ERR! Local Chrome version is not suitable
npm ERR! Downloading Chromium r706915...
npm ERR! ERROR: Failed to download Chromium r706915!
npm ERR! TypeError: Cannot read property 'folderPath' of undefined
npm ERR! at downloadChromium (/Users/weichangyue/sunlord/canyon/node_modules/estimo/scripts/chromeDetection.js:220:60)
npm ERR! at async findChrome (/Users/weichangyue/sunlord/canyon/node_modules/estimo/scripts/chromeDetection.js:287:24)
npm ERR! /Users/weichangyue/sunlord/canyon/node_modules/estimo/scripts/chromeDetection.js:288
npm ERR! await writeFile(chromeConfigPath, JSON.stringify({ executablePath: revisionInfo.executablePath }))
npm ERR! ^
npm ERR!
npm ERR! TypeError: Cannot read property 'executablePath' of null
npm ERR! at findChrome (/Users/weichangyue/sunlord/canyon/node_modules/estimo/scripts/chromeDetection.js:288:83)

@mbalabash
Copy link
Owner

Hello @SamWeichangyue !
Thanks for sharing this issue. I'll investigate what's going on with BrowserFetcher and will post update soon.

@ocavue
Copy link

ocavue commented Apr 10, 2021

Same error to me:

platform: M1 Macbook Air
Macos: 11.2.3
browser: N/A
node version: v15.14.0
pnpm version: 5.18.9

@mbalabash
Copy link
Owner

Looks like it was an issue with Puppeteer BrowserFetcher which was solved in newest version.

@SamWeichangyue @ocavue
Please, try to use estimo@2.2.4 to make sure that it works as expected.
It would be nice if you could post short update here. Cheers ✌️

@ocavue
Copy link

ocavue commented Apr 10, 2021

@mbalabash 2.2.4 still doesn't work

node_modules/.pnpm/estimo@2.2.4/node_modules/estimo: Running install script, failed in 1.8s
.../estimo@2.2.4/node_modules/estimo install$ node ./scripts/findChrome.js
│ Local Chrome version is not suitable
│ Downloading Chromium r706915...
│ ERROR: Failed to download Chromium r706915!
│ TypeError: Cannot read property 'folderPath' of undefined
│     at downloadChromium (/private/tmp/remirror/node_modules/.pnpm/estimo@2.2.4/node_modules/estimo/scripts/chromeDetection.js:220:60)
│     at async findChrome (/private/tmp/remirror/node_modules/.pnpm/estimo@2.2.4/node_modules/estimo/scripts/chromeDetection.js:290:24)
│ /private/tmp/remirror/node_modules/.pnpm/estimo@2.2.4/node_modules/estimo/scripts/chromeDetection.js:291
│   await writeFile(chromeConfigPath, JSON.stringify({ executablePath: revisionInfo.executablePath }))
│                                                                                   ^
│ TypeError: Cannot read property 'executablePath' of null
│     at findChrome (/private/tmp/remirror/node_modules/.pnpm/estimo@2.2.4/node_modules/estimo/scripts/chromeDetection.js:291:83)
└─ Failed in 1.8s

@mbalabash
Copy link
Owner

@ocavue Thanks for your update.

Let's try to locate the issue.
Could you please put this script into some folder on your computer:

const puppeteer = require("puppeteer-core");

(async () => {
  const browserFetcher = puppeteer.createBrowserFetcher();
  const revisionInfo = await browserFetcher.download("856583");

  console.log(`Chromium: r${revisionInfo.revision}`);
  console.log(`Chromium downloaded to: ${revisionInfo.folderPath}`);
  console.log("Chromium executable path:", revisionInfo.executablePath);

  const browser = await puppeteer.launch({
    executablePath: revisionInfo.executablePath,
  });
  const page = await browser.newPage();
  await page.goto("https://www.google.com");
  await browser.close();
})();

Run two commands:

npm install puppeteer-core
node ./index.js

and then, post the script output.

In this script we are trying to use Puppeteer BrowserFetcher directly, without any estimo code.
It'll help to define that the issue is not in the puppeteer itself, but in estimo.

@ocavue
Copy link

ocavue commented Apr 12, 2021

@mbalabash In your example, revisionInfo is undefined

@asherascout
Copy link

log:

➜ cat n.cjs                                                                                 
const puppeteer = require("puppeteer-core");

console.log('putr:', puppeteer);

const log = console.log;

(async () => {

  const browserFetcher = puppeteer.createBrowserFetcher();
  const revisionInfo = await browserFetcher.download("856583");

  log(`revisionInfo: ${revisionInfo}`);
  log(`Chromium: r${revisionInfo.revision}`);
  log(`Chromium downloaded to: ${revisionInfo.folderPath}`);
  log("Chromium executable path:", revisionInfo.executablePath);

  const browser = await puppeteer.launch({
    executablePath: revisionInfo.executablePath,
  });
  const page = await browser.newPage();
  await page.goto("https://www.google.com");
  await browser.close();
})();
➜ cat node_modules/puppeteer-core/package.json | grep '"version"'                
  "version": "8.0.0",
➜ node --version                                                                          
v15.14.0
➜ node ./n.cjs                                                                         
putr: PuppeteerNode {
  _changedProduct: false,
  _isPuppeteerCore: true,
  _projectRoot: '/private/tmp/e/node_modules/puppeteer-core',
  __productName: undefined,
  _preferredRevision: '856583'
}
revisionInfo: undefined
/private/tmp/e/n.cjs:13
  log(`Chromium: r${revisionInfo.revision}`);
                                 ^

TypeError: Cannot read property 'revision' of undefined
    at /private/tmp/e/n.cjs:13:34
➜                                                                                      

@ocavue
Copy link

ocavue commented Apr 12, 2021

If this is some puppeteer issues (e.g. puppeteer doesn’t support M1 Mac yet), at least we can try not to stop M1 users from installing this package. For example, I use M1 Macbook to develop the code and I only use estimo on my CI/CD server. Simplest solution: add a try cache block when executing the install script.

@mbalabash
Copy link
Owner

mbalabash commented Apr 12, 2021

The output of script if puppeteer was worked well should be like:

Chromium: r856583
Chromium downloaded to: /Users/mbalabash/Projects/estimo-test/node_modules/puppeteer-core/.local-chromium/mac-856583
Chromium executable path: /Users/mbalabash/Projects/estimo-test/node_modules/puppeteer-core/.local-chromium/mac-856583/chrome-mac/Chromium.app/Contents/MacOS/Chromium

There are some issues about this problem in puppeteer.


Added temporary error/message until puppeteer will fully support M1 Mac. Also, prevented install-script from failure if some error appeared.

You can try it in estimo@2.2.5.

@mbalabash
Copy link
Owner

After latest puppeteer release, error on Mac M1 has disappeared.
Released in estimo@2.2.6.

eh-am added a commit to grafana/pyroscope that referenced this issue Oct 13, 2021
build was failing since it couldn't install chromium in arm64
mbalabash/estimo#27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants