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

Cannot build Next.js application due to 'Cannot find module '../../../../src/app/layout'' TypeScript error in src/app/layout.tsx #15707

Closed
buraksakalli opened this issue Mar 16, 2023 · 2 comments
Labels
outdated scope: nextjs Issues related to NextJS support for Nx type: bug

Comments

@buraksakalli
Copy link

buraksakalli commented Mar 16, 2023

Solution

#14558 (comment)

Current Behavior

The current behavior is that when I try to build my Next.js application, I encounter a TypeScript error in the src/app/layout.tsx file that says "Cannot find module '../../../../src/app/layout' or its corresponding type declarations". This prevents the build process from completing successfully and I am unable to deploy my application.

Screenshot 2023-03-16 at 2 53 49 PM

Expected Behavior

The expected behavior is that I should be able to build my Next.js application without encountering a TypeScript error in the src/app/layout.tsx file. The build process should complete successfully. This would allow me to deploy my application as intended.

GitHub Repo

No response

Steps to Reproduce

  1. Create a next.js application that uses the app directory.
  2. Try to get a build - nx build appName

Nx Report

Node : 16.17.1
   OS   : darwin arm64
   yarn : 1.22.19

   nx                      : 15.9.0-beta.2
   @nrwl/js                : 15.9.0-beta.2
   @nrwl/jest              : 15.9.0-beta.2
   @nrwl/linter            : 15.9.0-beta.2
   @nrwl/workspace         : 15.9.0-beta.2
   @nrwl/cli               : 15.9.0-beta.2
   @nrwl/cypress           : 15.9.0-beta.2
   @nrwl/devkit            : 15.9.0-beta.2
   @nrwl/eslint-plugin-nx  : 15.9.0-beta.2
   @nrwl/next              : 15.9.0-beta.2
   @nrwl/react             : 15.9.0-beta.2
   @nrwl/rollup            : 15.9.0-beta.2
   @nrwl/tao               : 15.9.0-beta.2
   @nrwl/web               : 15.9.0-beta.2
   @nrwl/webpack           : 15.9.0-beta.2
   @nrwl/nx-cloud          : 15.2.1
   typescript              : 4.9.5

Failure Logs

npx nx build appName --skip-nx-cache

 >  NX   --skip-nx-cache disables the connection to Nx Cloud for the current run.

   The remote cache will not be read from or written to during this run.


> nx run appName:build:production

warn  - You have enabled experimental feature (appDir) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

info  - Compiled successfully
info  - Skipping linting
info  - Checking validity of types ...Failed to compile.

src/app/layout.tsx
Type error: Cannot find module '../../../../src/app/layout' or its corresponding type declarations.


 ——————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target build for project appName (9s)

    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]

error Command failed with exit code 1.

Additional Information

No response

@AgentEnder AgentEnder added the scope: nextjs Issues related to NextJS support for Nx label Mar 16, 2023
@ndcunningham
Copy link
Contributor

ndcunningham commented Mar 21, 2023

dupe of #14558

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: nextjs Issues related to NextJS support for Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants