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

**URL:** https://discourse.roots.io/t/bud-6-0-cannot-read-properties-of-undefined-reading-split/23382
**Category:** bud
**Tags:** sage10
**Created:** 2022-06-18T08:35:21Z
**Posts:** 8

## Post 1 by @fakenso — 2022-06-18T08:35:21Z

After upgrading to bud 6.0 and following first path from the [Bud v6.0.0 released](https://discourse.roots.io/t/bud-v6-0-0-released/23359) 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)
```

---

## Post 2 by @strarsis — 2022-06-18T23:14:58Z

So escaping `$` in variable value should fix the issue:

> **[Failed to load env - Cannot read properties of undefined (reading 'split') ·...](https://github.com/vercel/next.js/discussions/35818)**
>
> Verify canary release I verified that the issue exists in Next.js canary release Provide environment information Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: ...

---

## Post 3 by @fakenso — 2022-06-19T00:07:33Z

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'
}
```

---

## Post 4 by @strarsis — 2022-06-19T00:19:44Z

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

---

## Post 5 by @fakenso — 2022-06-19T09:43:24Z

Well everything is up to date :frowning:

---

## Post 6 by @fakenso — 2022-06-19T10:04:35Z

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](https://roots.io/salts.html).

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:

---

## Post 7 by @kellymears — 2022-07-01T23:01:21Z

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.

---

## Post 8 by @kellymears — 2022-07-03T22:45:34Z

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](https://github.com/roots/bud/blob/6e3996721b34a8b1588bcc5c069f3b20b3661d9d/tests/unit/bud/context/env.test.ts). 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.
