Bud 6.0 - Cannot read properties of undefined (reading ‘split’)

After upgrading to bud 6.0 and following first path from the Bud v6.0.0 released whenever I am trying to use yarn build / dev the error comes up:


/node_modules/dotenv-expand/lib/main.js:20
      const keyParts = parts[2].split(':-')
                                ^
TypeError: Cannot read properties of undefined (reading 'split')
    at /var/www/html/xxx.xx/bedrock/web/app/themes/xxx/node_modules/dotenv-expand/lib/main.js:20:33
    at Array.reduce (<anonymous>)
    at _interpolate (/var/www/html/xxx.xx/bedrock/web/app/themes/xxx/node_modules/dotenv-expand/lib/main.js:6:18)
    at expand (/var/www/html/xxx.xx/bedrock/web/app/themes/xxx/node_modules/dotenv-expand/lib/main.js:50:32)
    at get (file:///var/www/html/xxx.xx/bedrock/web/app/themes/xxx/node_modules/@roots/bud/lib/context/env.js:24:30)
    at file:///var/www/html/xxx.xx/bedrock/web/app/themes/xxx/node_modules/@roots/bud/lib/context/env.js:33:13
    at Array.reduce (<anonymous>)
    at new Env (file:///var/www/html/xxx.xx/bedrock/web/app/themes/xxx/node_modules/@roots/bud/lib/context/env.js:31:34)
    at makeContext (file:///var/www/html/xxx.xx/bedrock/web/app/themes/xxx/node_modules/@roots/bud/lib/context/index.js:21:17)
    at async bud (file:///var/www/html/xxx.xx/bedrock/web/app/themes/xxx/node_modules/@roots/bud/lib/cli/index.js:58:21)

1 Like

So escaping $ in variable value should fix the issue:

Well thanks, it worked, but a new error comes in:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /var/www/html/xx/bedrock/web/app/themes/xx/node_modules/@roots/bud-framework/package.json imported from /var/www/html/xx/bedrock/web/app/themes/xx/node_modules/@roots/bud-hooks/lib/service.js
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:645:7)
    at packageResolve (node:internal/modules/esm/resolve:873:14)
    at moduleResolve (node:internal/modules/esm/resolve:929:18)
    at defaultResolve (node:internal/modules/esm/resolve:1044:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

This has probably something to do with outdated packages.
Try npm outdated and then update the bud-related packages, one by one.

Well everything is up to date :frowning:

So, i’ve found the issue.
Everything is working when i delete salt keys from the .env file.
So basically i’ve generated new ones and everything is working. Keys were generated via WordPress Salts.

These are the faulty ones:

AUTH_KEY='N$d<475]Syb6/|DSA&q7z2l;Li@[hfJx)o?riz-X&s<xXz$7!]?H8nxCDQtwn^RE'
SECURE_AUTH_KEY='#x*B^Vlppd.<`t4IciZ$$UejKC`uB7s;aO$6FC2`jg]^e(|v=CH+]Rk(J2?,OaZg'
LOGGED_IN_KEY='nP$^4oL-%}Ia*l3z9{ki]1QXqW{Cy99{.94(o+0EZMMhAFtPb0H|#T8*`I,Cs0/_'
NONCE_KEY='jZ5;l`RilJM+X)@Ww[hx|MWRX_JCkz4>SiN@BCQppaOR_+QV&|^H`ya4z6}qO.32'
AUTH_SALT='I{gr5LCTf&=j}tjb[d7>q(:fR2RY>`,z7u[A*N;30`[[35>W]wE]g)cSw,1Ww,z9'
SECURE_AUTH_SALT='AzCIP/R`T#&4-Oz<V46L@X@Xqnv+VhDNbt+YuUmeicq,^Mhk9Tthg2>W9RPJ(m`?'
LOGGED_IN_SALT='?wsA|k20xv!VY4KvBk0B{U&F!}IRzxp>r--^F|9(t3vKFWt<`+pnL6{2d6HJmqPS'
NONCE_SALT='$=et66]kTt(+($c:mIRW1oh+B=E[gCQXFJr<VO+8J=a)*?,kOL;?^.5xac41%9pH'

I think it’s the kind of issue @ben should look into and investigate further :slight_smile:

2 Likes

It seems like bud was tripping up on your dotenv. it shouldn’t fail like that.

were the old values quoted? if they weren’t and they contained regexp-like characters, dotenv-expand might have choked on them.

This is because of an unescaped $ being interpolated by bud as variable expansion.

I was able to reproduce the issue exactly and write tests around it. Thanks for bringing it up @fakenso.

The next release of bud will not try to interpolate environment variables that are not sourced from [projectRoot]/.env. You will still need to escape $ in theme .env file but otherwise this shouldn’t be such a mystery in the future.

3 Likes