next.js
next.js copied to clipboard
Misleading info log after running `next dev`
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64
Binaries:
Node: 14.17.0
npm: 6.14.13
Yarn: 1.22.5
pnpm: N/A
Relevant packages:
next: 12.2.4-canary.9
eslint-config-next: 12.2.0
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
npx --no-install next info
Expected Behavior
I expected the logs to give accurate information regarding the environment variable loaded.
The logs give misleading information.
I used dotenv-cli
to provide a env.staging
file for env variables to the command next dev
. The env.staging
file was successfully loaded. The info logs are copied below:
daniel (main) $ yarn dev
yarn run v1.22.5
$ dotenv -e .env.staging -- next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Loaded env from /path_to_project/.env.local
Link to reproduction
https://codesandbox.io/s/info-logs-bug-5knxtu?file=/pages/_app.tsx
*EDIT: It seems codesandbox is messing with the env variables, so there's not much to see there.
To Reproduce
- Create a project
- Add
env.local
with a value, for exampleMESSAGE=local
- Add
env.staging
with the same key but different value. For exampleMESSAGE=staging
- Install
dotenv-cli
to be able to provideenv.staging
as env variable files - In package.json, replace the
dev
command withdotenv -e .env.staging -- next dev
- Run
yarn dev
Expected to