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

Usage with Nest CLI #76

Open
thisismydesign opened this issue Apr 8, 2021 · 5 comments
Open

Usage with Nest CLI #76

thisismydesign opened this issue Apr 8, 2021 · 5 comments

Comments

@thisismydesign
Copy link

Describe the bug

I'm trying to add Next to my existing NestJS project following the readme and basic example. I'm getting 404 for all pages.

My NestJS project is an example project following the getting started guide, so I imagined the integration to work out of the box. It uses the nest CLI for start and build.

I suspect the pages are not compiled, because I can't find them in the .next folder whereas running the basic example they're there. But I'm not sure how to adapt the existing setup using Nest CLI.

Expected behavior

A description in the readme to explain the usage with Next defaults.

To Reproduce

Repository URL: https://github.com/thisismydesign/nestjs-playground/tree/668dec84d2ff6544a1bc2f57cd874e44e33443f7

Version

  • next.js: 9.4.0
  • nest: 7.5.1
  • nest-next: 9.4.0

Additional context

Initial tsconfig:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  }

tsconfig updated by Next:

{
  "compilerOptions": {
    "module": "esnext",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve"
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}
@thisismydesign
Copy link
Author

Apparently calling a page index.tsx will produce this error. Calling it home.tsx as in your example works. Perhaps a mention of this in the readme?

I got the index example from here: https://github.com/kelvin-mai/nest-next-example

@kyle-mccarthy
Copy link
Owner

Hi sorry for the delay in getting back to you. I actually haven't tried to use the nest cli along with this package before, in my example I just use nodemon for the dev command.

That being said, I don't think that the problem is actually related to naming the page index.tsx. In the basic example I have a page in /pages/views/blog/index.tsx and render it in the controller without it 404ing.

@thisismydesign
Copy link
Author

I had pages/views/index.tsx and @Render('index'), you can reproduce it in the linked repo. Maybe I misunderstood how it's supposed to work, still, it was pretty confusing. Up to you how to handle this, feel free to just close.

@birksy89
Copy link

birksy89 commented May 2, 2021

I think I'm having a similar issue - I can't seem to get it to work with the Nest CLI

@krunalcodes
Copy link

@kyle-mccarthy I can confirm this. i have same issues @Render('index') throws an error if page is at pages/views/index.tsx but if it is at pages/views/blog/index.tsx it will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants