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

Error: TypeError: Cannot read properties of undefined (reading 'hasPeerDependency') #690

Closed
cspicuzza opened this issue Nov 23, 2021 · 3 comments
Assignees

Comments

@cspicuzza
Copy link
Sponsor

Description

Grabbed the newest Sage 10 build using Bud for packaging. I wanted to add react and typescript support but it's throwing errors

Steps to reproduce

  1. Download the latest Sage theme
  2. yarn install
  3. yarn add @roots/bud-react --dev
  4. yarn bud init

Expected behavior: [What you expect to happen]

I expected yarn to install all the peer dependencies for react

Actual behavior: [What actually happens]

It stops with this error:

Error: TypeError: Cannot read properties of undefined (reading 'hasPeerDependency')
error Command failed with exit code 1.

Reproduces how often: [What percentage of the time does it reproduce?]

Every time

Versions

Latest Sage build from Nov 22nd

Additional information

I'm in the process of rebuilding my Sage 10 theme with laravel mix to the newest with Bud

@QWp6t
Copy link
Sponsor Member

QWp6t commented Nov 24, 2021

Try running yarn bud build --install. If you're still running into issues, try running yarn install afterwards. I've personally had issues where bud init and bud build --install can cause side effects in node_modules, so running yarn install afterwards can resolve them.

The actual cause of this bug eludes us, but we're familiar with it and will hopefully get it fixed in the coming days.

In the meantime, thanks for checking out Bud.

@kellymears kellymears self-assigned this Nov 24, 2021
@kellymears kellymears added bug Something isn't working @roots/bud-react labels Nov 24, 2021
@kellymears
Copy link
Member

kellymears commented Nov 24, 2021

i'm looking into this now and can reproduce it. But, you do not need to install @roots/bud-react in a sage project. It is already going to be included by default (@roots/sage > @roots/bud-preset-wordpress > @roots/bud-react).

On a fresh install (after running a build) ./.budfiles/bud/webpack.config.js should list the paths webpack will resolve modules from on line 403 (or right around there).

It should look like this:

{
  "modules": [
    "resources",
    "node_modules",
    "[repo_root]/sage/node_modules",
    "[repo_root]/sage/node_modules/@roots/sage",
    "[repo_root]/sage/node_modules/@roots/bud-preset-wordpress",
    "[repo_root]/sage/node_modules/@roots/bud-stylelint",
    "[repo_root]/sage/node_modules/@roots/bud-prettier",
    "[repo_root]/sage/node_modules/@roots/bud-tailwindcss",
    "[repo_root]/sage/node_modules/@roots/bud-eslint",
    "[repo_root]/sage/node_modules/@roots/bud-preset-recommend",
    "[repo_root]/sage/node_modules/@roots/bud-react",
    "[repo_root]/sage/node_modules/@roots/bud-wordpress-dependencies",
    "[repo_root]/sage/node_modules/@roots/bud-wordpress-manifests",
    "[repo_root]/sage/node_modules/@roots/bud-wordpress-externals",
    "[repo_root]/sage/node_modules/@roots/bud-postcss",
    "[repo_root]/sage/node_modules/@roots/bud-babel",
    "[repo_root]/sage/node_modules/@roots/bud-entrypoints"
  ]
}

As long as yours includes @roots/bud-react then you should be good to go.

@kellymears
Copy link
Member

kellymears commented Dec 19, 2021

as of bud 5.0.0 i can no longer reproduce this, so i think it's fixed.

❯ yarn
❯ yarn add @roots/bud-react --dev
❯ yarn bud install
yarn run v1.22.17
$ ./node_modules/.bin/bud install

✅ nothing to install
✨  Done in 1.14s.

❯ yarn bud build
[sage] › ◼  bud          Timer run for: 277ms

./public

bud ✔ app.73e560.css                                                         ✔ min    3.77 kB
bud ✔ runtime.16d785.js                                                      ✔ min    1.12 kB
bud ✔ editor.0f52e1.js                                                       ✔ min    530 bytes
bud ✔ app.8bd132.js                                                          ✔ min    446 bytes

… compiled in 1s 252ms using webpack v5.65.0

[sage] [dashboard] › …  exiting cli
[sage] › ✔  exiting application
✨  Done in 2.40s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants