BudError - Could not import @roots/bud-framework/env

Hey everyone,

Hope you’re doing well! I’ve run into a bit of a snag while trying to fire up a Sage 10 project. Whenever I use “npm run start” or “yarn start” I get hit with this error

BudError
✘ Could not import @roots/bud-framework/env

I’ve got a feeling this is coming from the Bud Framework, but I’m not entirely sure how to tackle it. Just a heads up, my current Node.js version is 16.20.2.

Would love some guidance or insights if anyone has encountered this before. Thanks a bunch in advance!

image

Hi @mustterziu,

Could you share your package.json?

A common snag is not having your @roots/bud-* package versions matching. You can use bud upgrade to keep everything in sync.

Also, Node.js 16 left LTS last year - I would recommend switching to v20 and using something like Volta.

Tom.

1 Like

Hey @talss89 ,

Thanks a lot for jumping in! Really appreciate your help.

Here’s my package.json:

{
  "name": "xxxxx",
  "private": true,
  "version": "1.0.0",
  "browserslist": [
    "extends @roots/browserslist-config",
    "last 2 versions",
    "android 4",
    "opera 12"
  ],
  "engines": {
    "node": ">=16.20.0"
  },
  "type": "module",
  "scripts": {
    "start": "bud dev",
    "build": "bud build"
  },
  "devDependencies": {
    "@babel/core": "^7.0.0-0",
    "@roots/bud": "^6.20.0",
    "@roots/bud-framework": "^6.20.0",
    "@roots/bud-postcss": "^6.20.0",
    "@roots/bud-preset-recommend": "^6.20.0",
    "@roots/bud-preset-wordpress": "^6.20.0",
    "@roots/bud-sass": "^6.20.0",
    "@roots/bud-swc": "^6.20.0",
    "@roots/sage": "^6.20.0",
    "postcss": "^8.4.29",
    "remark": "^14.0.0",
    "stylelint": "^15.10.0",
    "stylelint-config-recommended": "^13.0.0",
    "stylelint-config-recommended-scss": "^13.1.0",
    "stylelint-scss": "^5.3.2",
    "webpack": "^5.0.0"
  },
  "dependencies": {
    "jquery": "^3.7.1",
    "npm": "^10.3.0"
  }
}

I’ve experimented with different Node.js versions, but the issue persists. Additionally, when attempting to upgrade, I run into this snag:

$ bud upgrade
bash: bud: command not found

Or

$ npm run bud upgrade
npm ERR! Missing script: "bud"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

You would need to run yarn bud upgrade

Can you reproduce this error on a fresh Sage install?

Hi @ben ,

I’ve been troubleshooting the issue, and when I run yarn bud upgrade, I encounter the following error:

$ yarn bud upgrade
yarn run v1.22.19
$ C:\Users\Musti\Desktop\Sites\pozhegubrothers\wp-content\themes\pozhegubrothers\node_modules\.bin\bud upgrade
node:internal/modules/esm/resolve:263
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\Musti\Desktop\Sites\pozhegubrothers\wp-content\themes\pozhegubrothers\node_modules\@roots\bud-framework\lib\methods\setPath\index.js' imported from C:\Users\Musti\Desktop\Sites\pozhegubrothers\wp-content\themes\pozhegubrothers\node_modules\@roots\bud-framework\lib\methods\index.js
    at finalizeResolution (node:internal/modules/esm/resolve:263:11)
    at moduleResolve (node:internal/modules/esm/resolve:908:10)
    at defaultResolve (node:internal/modules/esm/resolve:1131:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///C:/Users/Musti/Desktop/Sites/pozhegubrothers/wp-content/themes/pozhegubrothers/node_modules/@roots/bud-framework/lib/methods/setPath/index.js'
}

Node.js v21.6.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I’ve also tried installing a fresh theme, but unfortunately, the issue persists. Additionally, when I run yarn build within the new theme, I get the following error:

$ yarn build
yarn run v1.22.19
$ bud build
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Are you running those commands inside WSL? It looks like Node is loading modules from Windows paths.

Bud has to be run inside WSL on Windows. Anything else isn’t supported.

I’d do the following:

  1. Delete your node_modules folder
  2. Jump into WSL
  3. Install your Node dependencies again using yarn or npm
  4. Stay inside WSL when using any of the Sage / Bud npm or yarn scripts
1 Like

hey @talss89 ,

Your suggestion totally worked! Switched from Git Bash to the WSL terminal, followed your steps, and everything seems to be functioning smoothly now.

I’m encountering just one hiccup currently, which might not be directly related to the previous issue, but I’d love to get your insights. When I attempt to access the dev URL via localhost:3000, I’m getting this message:

 Network

 › Proxy  ┄ http://pozhegubrothers.local/
 › Dev    ┄ http://localhost:3000/
          ┄ http://192.168.85.191:3000/

 Press h to show help[server] › ✖  [HPM] Error occurred while proxying request localhost:3000/ to http://pozhegubrothers.local/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
[server] › ✖  [HPM] Error occurred while proxying request localhost:3000/favicon.ico to http://pozhegubrothers.local/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
[server] › ✖  [HPM] Error occurred while proxying request localhost:3000/ to http://pozhegubrothers.local/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
[server] › ✖  [HPM] Error occurred while proxying request localhost:3000/favicon.ico to http://pozhegubrothers.local/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

This is what I see in browser when accessing localhost:3000

Error occurred while trying to proxy: localhost:3000/

Any thoughts on how to address this?

Thanks,

Great, glad that worked.

I don’t use WSL myself, but the error you’re now seeing suggests that the WSL machine can’t resolve the upstream webserver. I’m not sure what http stack you’re using, but you need to ensure that http://pozhegubrothers.local/ can be resolved from within the WSL machine.

It may just be a case of adding an /etc/hosts file entry to the WSL machine to point pozhegubrothers.local at the interface where your HTTP server is listening.

1 Like

I truly appreciate your assistance!

I’ve examined the /etc/hosts file in Ubuntu, and it appears that my MAMP domain is listed there. Unfortunately, I haven’t been able to resolve the issue yet, but I’ll continue my research.

Thanks once again!

1 Like