Bud build cannot locate node_modules directory

Hi all

I’m trying to migrate to bud and am having trouble when referencing packages installed in node_modules. For example I have the following import directive in my main css entry point.

@import url("~bootstrap/scss/bootstrap.scss");

However, the build is not locating this file and throws the following error.

 │ Module build failed (from ../../node_modules/postcss-loader/dist/cjs.js):
│ │ SyntaxError
│ │ (1:33) from "postcss-import" plugin: resources/assets/styles/main.scss Failed to find '~bootstrap/scss/bootstrap.scss'
│ │   in [
│ │     resources/assets/styles
│ │   ]

Here is the contents of my bud.config.yml

setPath:
  - '@src'
  - 'resources/assets'
entry:
  - app
  - ['scripts/main.js', 'styles/main.scss']

Also the dev dependencies I have setup for bud

  "devDependencies": {
    "@roots/bud": "^6.23.1",
    "@roots/bud-babel": "^6.23.1",
    "@roots/bud-eslint": "^6.23.1",
    "@roots/bud-postcss": "^6.23.1",
    "@roots/bud-preset-wordpress": "^6.23.1",
    "@roots/bud-sass": "^6.23.1",
    "@roots/bud-stylelint": "^6.23.1"
  },

Does anyone know how to confiture bud / babel to correctly locate the node_modules directory?

Thanks in advance!

Try this instead?

@import 'bootstrap/scss/bootstrap';

That worked! Thank you :slight_smile:

I did have to turn off the import-notation rule in style lint though.

"import-notation": null
1 Like