Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9.3.2 requires .env file #11449

Closed
zanettin opened this issue Mar 28, 2020 · 5 comments · Fixed by #11496
Closed

9.3.2 requires .env file #11449

zanettin opened this issue Mar 28, 2020 · 5 comments · Fixed by #11496
Labels
please add a complete reproduction The issue lacks information for further investigation
Milestone

Comments

@zanettin
Copy link

Bug report

Describe the bug

since v.9.3.2 and PR #10525 on yarn dev you'll see an error, that the loader was not able to find the .env file on the root layer even with disabled/not set experimental flag.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. yarn dev
  2. check console output
  3. find on 3rd position the error

Expected behavior

no error if experimental flag is not set and no .env file exists on the project root

Screenshots

$ next
[ wait ]  starting the development server ...
[ info ]  waiting on http://localhost:3000 ...
> Error:  Failed to load env from .env { Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (fs.js:498:3)
    at tryReadSync (fs.js:332:20)
    at Object.readFileSync (fs.js:369:19)
    at Object.loadEnvConfig (/foo/myapp/node_modules/next/dist/lib/load-env-config.js:9:81)
    at new Server (/foo/myapp/node_modules/next/dist/next-server/server/next-server.js:49:39)
    at new DevServer (/foo/myapp/node_modules/next/dist/server/next-dev-server.js:1:2851)
    at createServer (/foo/myapp/node_modules/next/dist/server/next.js:2:105)
    at start (/foo/myapp/node_modules/next/dist/server/lib/start-server.js:1:323)
    at nextDev (/foo/myapp/node_modules/next/dist/cli/next-dev.js:21:279)
    at commands.(anonymous function).then.exec (/foo/myapp/node_modules/next/dist/bin/next:28:339) errno: -21, syscall: 'read', code: 'EISDIR' }

System information

  • OS: macOS 10.15.3
  • Browser: does not matter
  • Version of Next.js: 9.3.2

Additional context

none

@Timer Timer added this to the 9.3.3 milestone Mar 29, 2020
@Timer Timer added Type: Needs Investigation please add a complete reproduction The issue lacks information for further investigation labels Mar 29, 2020
@Timer
Copy link
Member

Timer commented Mar 29, 2020

I am not able to reproduce this. Can you please provide a full demo?

@zanettin
Copy link
Author

Hi @Timer
thanks a lot for the quick reply and taking care of this. guess i've found the underlaying issue of it but didn't find time by now to create a reproduction of it.
we use yarn workspaces and have multiple next apps within a mono-repo. therefore we have a package.json file for each app (no direct installs on this file) and one on the project root (all shared deps are installed here incl. dotenv and next). on the mentioned PR from above you check (https://github.com/zeit/next.js/pull/10525/files#diff-27f9c1f2b5ef159bccd52c544f8bb4d1R23) if dotenv is installed on the first package.json you'll find and on our implementation this is not the case. but we have it installed on the root package.json. after installing dotenv on my sub projects, i was able to get rid of the error.

from my pov it would be great, if you could check the first package.json you'll get with find-up plus checking if there is another package.json on the root of the project if for example next is not installed on that package.json.

pls let me know if you'd like to have a reproduction or not and i'll will create one 👍
thanks again!

@zanettin
Copy link
Author

zanettin commented Mar 29, 2020

here's the reproduction repo. hope that helps.
https://github.com/zanettin/nextjs-11449

have added 2 similar workspaces. A is throwing the error and B doesn't because dotenv is installed on the package.json of the workspace itself and not just on the root level. both versions are working (identical output except of the terminal error).

@ravid7000
Copy link

ravid7000 commented Mar 30, 2020

I also got this issue. Nextjs reading .env as file but it is a directory. In my case I'm using .env as directory to store different .env for different environments, cannot use single .env file.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
please add a complete reproduction The issue lacks information for further investigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants