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

Build Crash on Windows (TypeError) for _isAppDir #51225

Closed
1 task done
ovflowd opened this issue Jun 13, 2023 · 16 comments · Fixed by #53876
Closed
1 task done

Build Crash on Windows (TypeError) for _isAppDir #51225

ovflowd opened this issue Jun 13, 2023 · 16 comments · Fixed by #53876
Assignees
Labels
linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@ovflowd
Copy link

ovflowd commented Jun 13, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Binaries:
  Node: 18.13.0
  npm: 9.6.7
  Yarn: 1.22.19
  pnpm: 8.6.0
Relevant packages:
  next: 13.4.5
  eslint-config-next: 13.4.5
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3

Which area(s) of Next.js are affected? (leave empty if unsure)

Operating System (Windows, MacOS, Linux)

Link to the code that reproduces this issue or a replay of the bug

nodejs/nodejs.org#5426

To Reproduce

The Issue actually happens within GitHub Actions on a Windows Runner. And seems to be fine on Linux and macOS builds. It seems to be related to "app directory" even thought we do not use the "app directory feature"

Describe the Bug

build: TypeError: Cannot read properties of undefined (reading '_isAppDir')
build:     at D:\a\nodejs.org\nodejs.org\node_modules\next\dist\export\index.js:420:39
build:     at Array.filter (<anonymous>)
build:     at D:\a\nodejs.org\nodejs.org\node_modules\next\dist\export\index.js:419:43
build:     at async Span.traceAsyncFn (D:\a\nodejs.org\nodejs.org\node_modules\next\dist\trace\trace.js:103:20)
build:     at async D:\a\nodejs.org\nodejs.org\node_modules\next\dist\build\index.js:1489:21
build:     at async Span.traceAsyncFn (D:\a\nodejs.org\nodejs.org\node_modules\next\dist\trace\trace.js:103:20)
build:     at async D:\a\nodejs.org\nodejs.org\node_modules\next\dist\build\index.js:1345:17
build:     at async Span.traceAsyncFn (D:\a\nodejs.org\nodejs.org\node_modules\next\dist\trace\trace.js:103:20)
build:     at async build (D:\a\nodejs.org\nodejs.org\node_modules\next\dist\build\index.js:145:[29](https://github.com/nodejs/nodejs.org/actions/runs/5253121230/jobs/9490043267?pr=5426#step:7:30))
build: ERROR: command finished with error: command (D:\a\nodejs.org\nodejs.org) npm run build exited (1)
command (D:\a\nodejs.org\nodejs.org) npm run build exited (1)

GitHub Action: https://github.com/nodejs/nodejs.org/actions/runs/5253121230/jobs/9490043267?pr=5426

Expected Behavior

The build should succeed as in the other systems (Linux, macOS).

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1504

@ovflowd ovflowd added the bug Issue was opened via the bug report template. label Jun 13, 2023
@ovflowd
Copy link
Author

ovflowd commented Aug 9, 2023

Hey @styfle sorry for the ping! We're still seeing this in our CI!

I.e.: https://github.com/nodejs/nodejs.org/actions/runs/5806595272/job/15739809537?pr=5617

@styfle styfle added kind: bug linear: next Confirmed issue that is tracked by the Next.js team. and removed bug Issue was opened via the bug report template. labels Aug 9, 2023
@styfle styfle self-assigned this Aug 9, 2023
@styfle
Copy link
Member

styfle commented Aug 9, 2023

@ovflowd I tried building that repo using Windows 11 and it works fine.

I created PR #53818 with a potential fix but it would be good to get the steps to reproduce.

I suspect it might have something to do with this experimental feature so you could try disabling that: https://github.com/nodejs/nodejs.org/blob/25717d37e28243cbfbc5910d80c7c8459026220b/next.config.mjs#L51-L53

@ovflowd
Copy link
Author

ovflowd commented Aug 9, 2023

I suspect it might have something to do with this experimental feature so you could try disabling that: nodejs/nodejs.org@25717d3/next.config.mjs#L51-L53

I remember I had to add that due to a momentary bug on Next.js that it was including SWC binaries within the Edge Runtimes, which was causing the runtimes to exceed the max 50mb size... Is that fixed?

@ovflowd
Copy link
Author

ovflowd commented Aug 9, 2023

I created PR #53818 with a potential fix but it would be good to get the steps to reproduce.

Super appreciate the PR! Also, @bmuenzenmeyer was facing this on his Windows 11 machine.

@bmuenzenmeyer
Copy link
Contributor

bmuenzenmeyer commented Aug 10, 2023

I get this error on the nodejs repo, at the tip of current development.

For example, from nodejs/nodejs.org@9a45ee1

git clone [email protected]:nodejs/nodejs.org.git node-site
cd node-site
nvm use
npm ci
npx turbo deploy

if you have a canary build handy, you can directly install it here to verify. I tried to decipher from this github action if next makes canaries on each pr, I saw a reference to next 13.4.14-canary.1 - but I think that's pointing to a released canary and the line is symlinking to the local checkout. installing that version still presents the error

error output
/c/src/nodejsorg-4 (main) 🔥 npx turbo deploy
• Running deploy
• Remote caching disabled
deploy: cache miss, executing 463091786f71314b
deploy: 
deploy: > [email protected] deploy
deploy: > cross-env NEXT_STATIC_EXPORT=true npm run build
deploy: 
deploy: 
deploy: > [email protected] prebuild
deploy: > npm run scripts:generate-next-data
deploy: 
deploy: 
deploy: > [email protected] scripts:generate-next-data
deploy: > cross-env NODE_NO_WARNINGS=1 node scripts/generate-next-data/index.mjs
deploy: 
deploy: 
deploy: > [email protected] build
deploy: > cross-env NODE_NO_WARNINGS=1 next build
deploy: 
deploy: - warn You have enabled experimental features (largePageDataBytes, outputFileTracingExcludes) in next.config.mjs.
deploy: - warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
deploy: 
deploy: - info Creating an optimized production build...
deploy: - info Compiled successfully
deploy: - info Skipping validation of types
deploy: - info Skipping linting
deploy: - info Collecting page data...
deploy: 
deploy: > Build error occurred
deploy: TypeError: Cannot read properties of undefined (reading '_isAppDir')
deploy:     at C:\src\nodejsorg-4\node_modules\next\dist\export\index.js:422:39
deploy:     at Array.filter (<anonymous>)
deploy:     at C:\src\nodejsorg-4\node_modules\next\dist\export\index.js:421:43
deploy:     at async Span.traceAsyncFn (C:\src\nodejsorg-4\node_modules\next\dist\trace\trace.js:103:20)
deploy:     at async C:\src\nodejsorg-4\node_modules\next\dist\build\index.js:1597:21
deploy:     at async Span.traceAsyncFn (C:\src\nodejsorg-4\node_modules\next\dist\trace\trace.js:103:20)
deploy:     at async C:\src\nodejsorg-4\node_modules\next\dist\build\index.js:1453:17
deploy:     at async Span.traceAsyncFn (C:\src\nodejsorg-4\node_modules\next\dist\trace\trace.js:103:20)
deploy:     at async build (C:\src\nodejsorg-4\node_modules\next\dist\build\index.js:148:29)
deploy: ERROR: command finished with error: command (C:\src\nodejsorg-4) npm run deploy exited (1)
deploy: command (C:\src\nodejsorg-4) npm run deploy exited (1)

 Tasks:    0 successful, 1 total
Cached:    0 cached, 1 total
  Time:    27.172s
Failed:    //#deploy

 ERROR  run failed: command  exited (1)

happy to provide more debug data

npx next info
(node:22328) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

    Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 18.13.0
      npm: N/A
      Yarn: N/A
      pnpm: 7.26.0
    Relevant Packages:
      next: 13.4.14-canary.1
      eslint-config-next: 13.4.12
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

@ovflowd
Copy link
Author

ovflowd commented Aug 10, 2023

@bmuenzenmeyer can you format your error output on a "markdown code block"?

@ovflowd
Copy link
Author

ovflowd commented Aug 10, 2023

FYI @styfle I removed that experimental flag, but sadly (nodejs/nodejs.org#5617) is still failing. I assume your PR on Next.js might fix this issue.

@styfle
Copy link
Member

styfle commented Aug 10, 2023

@ovflowd I tried to reproduce locally but it builds fine for me. Are you able to reproduce the issue locally?

Here's what I tried:

git clone https://github.com/nodejs/nodejs.org
cd nodejs.org
git checkout chore/add-static-builds-to-ci
npm ci
npm run build

This was commit d83cfeb and I'm seeing a successful build using Windows 11 64bit ARM running in a VM.

@ovflowd
Copy link
Author

ovflowd commented Aug 10, 2023

I can try on my Windows machine, but @bmuenzenmeyer is a Windows user and he was able to reproduce. Let me try this now.

@ovflowd
Copy link
Author

ovflowd commented Aug 10, 2023

@styfle note that you're using the wrong command. It's not npm run build but npm run deploy

@ovflowd
Copy link
Author

ovflowd commented Aug 10, 2023

  • npm run build creates a minimal version of the application to be deployed on Vercel
  • npm run deploy creates a build with static export (target: export)

@ovflowd
Copy link
Author

ovflowd commented Aug 10, 2023

I was able to reproduce with:

C:\Users\Claudio Wunder\GitHub\nodejs.org>npm run deploy

> [email protected] deploy
> cross-env NEXT_STATIC_EXPORT=true npm run build


> [email protected] prebuild
> npm run scripts:generate-next-data


> [email protected] scripts:generate-next-data
> cross-env NODE_NO_WARNINGS=1 node scripts/generate-next-data/index.mjs


> [email protected] build
> cross-env NODE_NO_WARNINGS=1 next build

- warn You have enabled experimental features (largePageDataBytes, outputFileTracingExcludes) in next.config.mjs.
- warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

- info Creating an optimized production build
- info Compiled successfully
- info Skipping validation of types
- info Skipping linting
- info Collecting page data

> Build error occurred
TypeError: Cannot read properties of undefined (reading '_isAppDir')
    at C:\Users\Claudio Wunder\GitHub\nodejs.org\node_modules\next\dist\export\index.js:422:39
    at Array.filter (<anonymous>)
    at C:\Users\Claudio Wunder\GitHub\nodejs.org\node_modules\next\dist\export\index.js:421:43
    at async Span.traceAsyncFn (C:\Users\Claudio Wunder\GitHub\nodejs.org\node_modules\next\dist\trace\trace.js:103:20)
    at async C:\Users\Claudio Wunder\GitHub\nodejs.org\node_modules\next\dist\build\index.js:1579:21
    at async Span.traceAsyncFn (C:\Users\Claudio Wunder\GitHub\nodejs.org\node_modules\next\dist\trace\trace.js:103:20)
    at async C:\Users\Claudio Wunder\GitHub\nodejs.org\node_modules\next\dist\build\index.js:1435:17
    at async Span.traceAsyncFn (C:\Users\Claudio Wunder\GitHub\nodejs.org\node_modules\next\dist\trace\trace.js:103:20)
    at async build (C:\Users\Claudio Wunder\GitHub\nodejs.org\node_modules\next\dist\build\index.js:146:29)

C:\Users\Claudio Wunder\GitHub\nodejs.org>

Next Info:

C:\Users\Claudio Wunder\GitHub\nodejs.org>npx --no-install next info
(node:31636) ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:31636) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time

    Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 18.17.1
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant Packages:
      next: 13.4.12
      eslint-config-next: 13.4.12
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A


warn  - Latest canary version not detected, detected: "13.4.12", newest: "13.4.14-canary.1".
        Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
        Read more - https://nextjs.org/docs/messages/opening-an-issue

C:\Users\Claudio Wunder\GitHub\nodejs.org>

@styfle
Copy link
Member

styfle commented Aug 10, 2023

@ovflowd Thanks I can reproduce the issue now.

Looks like the root cause is that getStaticPaths() in your app is passing file paths instead of url paths.

https://github.com/nodejs/nodejs.org/blob/8225312fe8d26129e40e222ffed93f92fcfd3c41/pages/%5B...path%5D.tsx#L85

I can see backslashes here but they should be forward slashes.

@ovflowd
Copy link
Author

ovflowd commented Aug 10, 2023

I can see backslashes here but they should be forward slashes.

Hmm, afaik they should be forwarded slashes. Is this happening due to Windows FS using backslashes? Let me play around here and build an URL instead of file path. (But that does make sense!)

@ovflowd
Copy link
Author

ovflowd commented Aug 10, 2023

I can ack that using platform-specific separators fixes the issue. nodejs/nodejs.org#5617

Not sure if the bug-fix on Next.js is still needed, but def worth investigating imo.

@kodiakhq kodiakhq bot closed this as completed in #53876 Aug 10, 2023
kodiakhq bot pushed a commit that referenced this issue Aug 10, 2023
This normalizes the backslash for windows users who accidentally use `\` in the request paths instead of the expected `/`.

For example, in nodejs/nodejs.org#5617 the slash was hardcoded for split that caused the backlash to remain the the `getStaticPaths()` result.

- Fixes #51225
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
linear: next Confirmed issue that is tracked by the Next.js team. locked
Projects
None yet
3 participants