webhintio / hint

💡 A hinting engine for the web
https://webhint.io/
Apache License 2.0
3.61k stars 667 forks source link

[Bug] `yarn build` fails on a fresh clone of this repository #5657

Open hamirmahal opened 1 year ago

hamirmahal commented 1 year ago

🐞 Bug report

Description

yarn build seems to fail because "prebuild": "node scripts/prebuild.js", fails.

Really long error output
``` $ yarn build yarn run v1.22.19 $ node scripts/prebuild.js Processing "/home/hamir/repositories/hint/packages/configuration-accessibility/package.json" Processing "/home/hamir/repositories/hint/packages/configuration-all/package.json" Processing "/home/hamir/repositories/hint/packages/configuration-development/package.json" Processing "/home/hamir/repositories/hint/packages/configuration-progressive-web-apps/package.json" Processing "/home/hamir/repositories/hint/packages/configuration-web-recommended/package.json" Processing "/home/hamir/repositories/hint/packages/connector-jsdom/package.json" Processing "/home/hamir/repositories/hint/packages/connector-local/package.json" Processing "/home/hamir/repositories/hint/packages/connector-puppeteer/package.json" Processing "/home/hamir/repositories/hint/packages/create-hint/package.json" Processing "/home/hamir/repositories/hint/packages/create-hintrc/package.json" Processing "/home/hamir/repositories/hint/packages/create-parser/package.json" Processing "/home/hamir/repositories/hint/packages/extension-browser/package.json" Prebuilding... cd /home/hamir/repositories/hint/packages/extension-browser/ && npm run prebuild npm WARN ignoring workspace config at /home/hamir/repositories/hint/packages/extension-browser/.npmrc > @hint/extension-browser@2.4.14 prebuild > npm-run-all prebuild:* npm WARN ignoring workspace config at /home/hamir/repositories/hint/packages/extension-browser/.npmrc > @hint/extension-browser@2.4.14 prebuild:assets > copyfiles -u 1 "./src/**/*.{html,json,png}" dist/bundle && copyfiles -f "./src/*.svg" dist/bundle && copyfiles -f "./src/browser-action/*.svg" dist/bundle/browser-action npm WARN ignoring workspace config at /home/hamir/repositories/hint/packages/extension-browser/.npmrc > @hint/extension-browser@2.4.14 prebuild:css > tcm src Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/app.base.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/app.fluent.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/app.photon.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/button.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/external-docs.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/inspect-button.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/notification.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/label.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/print-link.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/radio.base.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/progress-bar.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/checkbox.base.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/radio.fluent.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/radio.photon.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/summary.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/toggle.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/valid-input.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/page.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/config.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/analyze.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/config/example.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/external-link.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/config/header.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/config/section.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/error.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/config/sections/categories.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/results.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/results/category-summary.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/source-code.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/results/category.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/results/header.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/results/message-group.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/config/label.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/results/problem.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/pages/results/hint.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/checkbox.fluent.css.d.ts Wrote /home/hamir/repositories/hint/packages/extension-browser/src/devtools/views/controls/checkbox.photon.css.d.ts npm WARN ignoring workspace config at /home/hamir/repositories/hint/packages/extension-browser/.npmrc > @hint/extension-browser@2.4.14 prebuild:hints > node ./scripts/import-hints.js Created: /home/hamir/repositories/hint/packages/extension-browser/src/shared/hints.import.ts Created: /home/hamir/repositories/hint/packages/extension-browser/src/shared/metas.import.ts npm WARN ignoring workspace config at /home/hamir/repositories/hint/packages/extension-browser/.npmrc > @hint/extension-browser@2.4.14 prebuild:i18n > node ./scripts/create-i18n.js Created: /home/hamir/repositories/hint/packages/extension-browser/src/shared/i18n.import.ts Processing "/home/hamir/repositories/hint/packages/extension-vscode/package.json" Processing "/home/hamir/repositories/hint/packages/formatter-codeframe/package.json" Processing "/home/hamir/repositories/hint/packages/formatter-excel/package.json" Processing "/home/hamir/repositories/hint/packages/formatter-html/package.json" Processing "/home/hamir/repositories/hint/packages/formatter-json/package.json" Processing "/home/hamir/repositories/hint/packages/formatter-stylish/package.json" Processing "/home/hamir/repositories/hint/packages/formatter-summary/package.json" Processing "/home/hamir/repositories/hint/packages/hint/package.json" Processing "/home/hamir/repositories/hint/packages/hint-apple-touch-icons/package.json" Processing "/home/hamir/repositories/hint/packages/hint-axe/package.json" Prebuilding... cd /home/hamir/repositories/hint/packages/hint-axe/ && npm run prebuild npm WARN ignoring workspace config at /home/hamir/repositories/hint/packages/hint-axe/.npmrc > @hint/hint-axe@4.4.20 prebuild > node ./scripts/create.js node:internal/modules/cjs/loader:446 throw err; ^ Error: Cannot find module '/home/hamir/repositories/hint/node_modules/@hint/utils-types/dist/src/index.js'. Please verify that the package.json has a valid "main" entry at tryPackage (node:internal/modules/cjs/loader:438:19) at Module._findPath (node:internal/modules/cjs/loader:680:18) at Module._resolveFilename (node:internal/modules/cjs/loader:1063:27) at Module._load (node:internal/modules/cjs/loader:922:27) at Module.require (node:internal/modules/cjs/loader:1143:19) at require (node:internal/modules/cjs/helpers:110:18) at Object. (/home/hamir/repositories/hint/packages/hint-axe/scripts/create/create-metas.js:1:22) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) { code: 'MODULE_NOT_FOUND', path: '/home/hamir/repositories/hint/node_modules/@hint/utils-types/package.json', requestPath: '@hint/utils-types' } Node.js v18.16.1 npm ERR! Lifecycle script `prebuild` failed with error: npm ERR! Error: command failed npm ERR! in workspace: @hint/hint-axe@4.4.20 npm ERR! at location: /home/hamir/repositories/hint/packages/hint-axe /home/hamir/repositories/hint/scripts/prebuild.js:20 return reject(new Error('NoExitCodeZero')); ^ Error: NoExitCodeZero at ChildProcess. (/home/hamir/repositories/hint/scripts/prebuild.js:20:31) at ChildProcess.emit (node:events:513:28) at ChildProcess._handle.onexit (node:internal/child_process:291:12) Node.js v18.16.1 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ```

Details

I'm using WSL2 on a Windows 10 desktop device.

hamirmahal commented 1 year ago

I'm not seeing /home/hamir/repositories/hint/node_modules/@hint/utils-types/dist/src/index.js, like the error message says.

image

hamirmahal commented 1 year ago

I'm using version 18 of node.

$  nvm ls
->     v18.16.1
default -> lts/* (-> v18.16.1)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.16.1) (default)
stable -> 18.16 (-> v18.16.1) (default)
lts/* -> lts/hydrogen (-> v18.16.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.1 (-> N/A)
lts/hydrogen -> v18.16.1
hamirmahal commented 1 year ago

I tried just now with version 16 and yarn build still failed.

$  nvm ls
->     v16.20.1
       v18.16.1
default -> lts/* (-> v18.16.1)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.16.1) (default)
stable -> 18.16 (-> v18.16.1) (default)
lts/* -> lts/hydrogen (-> v18.16.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.1
lts/hydrogen -> v18.16.1
hamirmahal commented 1 year ago

This is what seems to be happening.

  1. yarn build kicks off
  2. "prebuild": "node scripts/prebuild.js",, which does
  3. cd /home/hamir/repositories/hint/packages/hint-axe/ && npm run prebuild, which does
  4. "prebuild": "node ./scripts/create.js", in packages/hint-axe/package.json, which does
  5. node packages/hint-axe/scripts/create.js, which does const { createMetas } = require("./create/create-metas");, which is a problem because

packages/hint-axe/scripts/create/create-metas.js does const { Severity } = require('@hint/utils-types'); on its first line, and Node Cannot find module '/home/hamir/repositories/hint/node_modules/@hint/utils-types/dist/src/index.js'..

hamirmahal commented 1 year ago

As a temporary workaround, I did

  1. cd /home/hamir/repositories/hint/node_modules/@hint/utils-types and
  2. npm run build

and yarn build gets farther, but still fails later on.

thectogeneral commented 11 months ago

The reason it is failing is because you are either not using the right node version or the right npm version.

Also, you might not have sudo privileges.

As a Linux user, I use 'sudo yarn build`

I also had the same issue, and this is how I solved them.

If you keep these in checks, you shouldn't have any problem @hamirmahal

hamirmahal commented 11 months ago

I'm using WSL2.

hamirmahal commented 11 months ago

I get an error when I try sudo yarn build.

$  sudo yarn build
[sudo] password for hamir: 
sudo: yarn: command not found
hamirmahal commented 11 months ago

image

hamirmahal commented 11 months ago

What versions of node and npm are you using?

hamirmahal commented 11 months ago
$  nvm ls
->     v18.18.0
default -> lts/* (-> v18.18.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.18.0) (default)
stable -> 18.18 (-> v18.18.0) (default)
lts/* -> lts/hydrogen (-> v18.18.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.18.0
$  npm -v
9.8.1
hamirmahal commented 11 months ago

image

thectogeneral commented 11 months ago

I get an error when I try sudo yarn build.


$  sudo yarn build

[sudo] password for hamir: 

sudo: yarn: command not found

You can install Yarn on your WSL2 and then use the node version 14

thectogeneral commented 11 months ago

What versions of node and npm are you using?

I use node version 14 and npm version 10