next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Misleading info log after running `next dev`

Open dgrcode opened this issue 2 years ago • 0 comments

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

  1. Create a project
  2. Add env.local with a value, for example MESSAGE=local
  3. Add env.staging with the same key but different value. For example MESSAGE=staging
  4. Install dotenv-cli to be able to provide env.staging as env variable files
  5. In package.json, replace the dev command with dotenv -e .env.staging -- next dev
  6. Run yarn dev

Expected to

dgrcode avatar Aug 02 '22 16:08 dgrcode