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

NestJS example not working #88

Open
ghost opened this issue May 4, 2023 · 3 comments
Open

NestJS example not working #88

ghost opened this issue May 4, 2023 · 3 comments

Comments

@ghost
Copy link

ghost commented May 4, 2023

Hello. Currently it's not possible to run the NestJS example with the current TS configuration. If trying to run pnpm start yields:

> nest start

DeprecationWarning: 'getMutableClone' has been deprecated since v4.0.0. Use an appropriate `factory.update...` method instead, use `setCommentRange` or `setSourceMapRange`, and avoid setting `parent`.
src/main.ts:4:5 - error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.

4 if (import.meta.env.PROD) {
      ~~~~~~~~~~~
src/main.ts:4:17 - error TS2339: Property 'env' does not exist on type 'ImportMeta'.

4 if (import.meta.env.PROD) {
                  ~~~

Found 2 error(s).

And then, changing module to "es2020" and adding 'moduleResolution: "node"' in tsconfig.json:

DeprecationWarning: 'getMutableClone' has been deprecated since v4.0.0. Use an appropriate `factory.update...` method instead, use `setCommentRange` or `setSourceMapRange`, and avoid setting `parent`.
src/main.ts:4:17 - error TS2339: Property 'env' does not exist on type 'ImportMeta'.

4 if (import.meta.env.PROD) {
                  ~~~

Is it outdated or did I forget some configuration?

@WinmezzZ
Copy link

WinmezzZ commented May 11, 2023

Try add this two options into tsconfig.json

{
   "compilerOptions": {
    // ...
     "module": "ESNext",
     "moduleResolution": "node",
    // ...
   }
}

@ghost
Copy link
Author

ghost commented May 11, 2023

I tried it and had the same output, only this time, I tried to execute from within the "examples" folder of this repository, so another error was added into the fold:

> [email protected] start /home/stanley/ent/vite-plugin-node/examples/nest
> nest start

src/main.ts:4:17 - error TS2339: Property 'env' does not exist on type 'ImportMeta'.

4 if (import.meta.env.PROD) {
                  ~~~
vite.config.ts:2:32 - error TS2307: Cannot find module 'vite-plugin-node' or its corresponding type declarations.

2 import { VitePluginNode } from 'vite-plugin-node';
                                 ~~~~~~~~~~~~~~~~~~

Found 2 error(s).

 ELIFECYCLE  Command failed with exit code 1.

Some remarks:

  • I can see that the project is using some kind of workspaces of pnpm, do I have to issue an specific command to help the examples/nest project find the parent "vite-plugin-node"? Sorry, I'm new to this;
  • Are you able to run this example project locally? I have a fresh clone of this repository and I've changed only the things you've suggested, in tsconfig.json of the examples/nest project;
  • I'm trying to launch the NestJS server from the examples/nest project, with pnpm start;

@ghost
Copy link
Author

ghost commented May 11, 2023

My guess is that I need to create a type definition for ImportMetaEnv manually: https://vitejs.dev/guide/env-and-mode.html#intellisense-for-typescript

I'll try this later.

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

1 participant