Getting error on npm run dev after prisma User model addition

Failed to load env from D:\next-app.env

Failed to load env from D:\next-app.env TypeError: Cannot read properties of undefined (reading ‘split’)
at D:\next-app\node_modules@next\env\dist\index.js:1:311
at Array.reduce ()
at _interpolate (D:\next-app\node_modules@next\env\dist\index.js:1:125)
at expand (D:\next-app\node_modules@next\env\dist\index.js:1:709)
at processEnv (D:\next-app\node_modules@next\env\dist\index.js:1:4057)
at loadEnvConfig (D:\next-app\node_modules@next\env\dist\index.js:1:5038)
at nextDev (D:\next-app\node_modules\next\dist\cli\next-dev.js:191:55)
at async main (D:\next-app\node_modules\next\dist\bin\next:156:5)
⨯ Failed to load env from D:\next-app.env TypeError: Cannot read properties of undefined (reading ‘split’)
at D:\next-app\node_modules@next\env\dist\index.js:1:311
at Array.reduce ()
at _interpolate (D:\next-app\node_modules@next\env\dist\index.js:1:125)
at expand (D:\next-app\node_modules@next\env\dist\index.js:1:709)
at processEnv (D:\next-app\node_modules@next\env\dist\index.js:1:4057)
at loadEnvConfig (D:\next-app\node_modules@next\env\dist\index.js:1:5038)
at loadConfig (D:\next-app\node_modules\next\dist\server\config.js:595:28)
at initialize (D:\next-app\node_modules\next\dist\server\lib\router-server.js:48:46)
at getRequestHandlers (D:\next-app\node_modules\next\dist\server\lib\start-server.js:85:41)
at Server. (D:\next-app\node_modules\next\dist\server\lib\start-server.js:219:42)
⨯ Failed to load env from D:\next-app.env TypeError: Cannot read properties of undefined (reading ‘split’)
at D:\next-app\node_modules@next\env\dist\index.js:1:311
at Array.reduce ()
at _interpolate (D:\next-app\node_modules@next\env\dist\index.js:1:125)
at expand (D:\next-app\node_modules@next\env\dist\index.js:1:709)
at processEnv (D:\next-app\node_modules@next\env\dist\index.js:1:4057)
at loadEnvConfig (D:\next-app\node_modules@next\env\dist\index.js:1:5038)
at Watchpack. (D:\next-app\node_modules\next\dist\server\lib\router-utils\setup-dev.js:1240:44)
at Watchpack.emit (node:events:517:28)
at Watchpack._onTimeout (D:\next-app\node_modules\watchpack\lib\watchpack.js:379:8)
at listOnTimeout (node:internal/timers:569:17)

The nextapp is working fine after I stopped the dev server, ran “npx prisma migrate dev” and ran “npm run dev”, which updated the schema.

But while running the “npm run dev” the second time, I’m getting the above said error again. The app is functioning fine, with db operations running ok. But I want to know if I configured the .env file correctly? Thanks in advance.

Do you have a $ in your .env file? If so, that might be the problem. Check out this issue.

My db password has $ in .env file. Looks like I need to escape it or change it.
Thank you @Programmist :smile:

1 Like