Use .env.client : The 'import.meta' meta-property is only allowed when the '--module' option is 'es2
I need to use env variables in my code and following the doc import.meta.env.REACT_APP_PUBLIC_STRIPE_PUBLIC_KEY get this error :
The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'.ts(1343)tsconfig.json) is not set to a module system that supports import.meta. import.meta, you need to set the --module option in your tsconfig.json file to 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'. REACT_APP_ and you can access them using import.meta.env.REACT_APP_YOUR_VAR_NAME as stated in the Wasp documentation (https://wasp-lang.dev/docs/project/env-vars).tsconfig.json in the project root folder to include:
wasp versiontsconfig.jsontsconfig.jsontsconfig.jsontsconfig.jsontsconfig.jsonimport.metaimport.meta--moduleREACT_APP_import.meta.env.REACT_APP_YOUR_VAR_NAMECannot find module 'wasp/client/operations'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?ts(2792)Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'.wasp version{
"compilerOptions": {
"module": "es2020",
// other options...
}
}{
"compilerOptions": {
"module": "ES2022"
}
}// =============================== IMPORTANT =================================
//
// This file is only used for Wasp IDE support. You can change it to configure
// your IDE checks, but none of these options will affect the TypeScript
// compiler. Proper TS compiler configuration in Wasp is coming soon :)
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
// We're bundling all code in the end so this is the most appropriate option,
// it's also important for autocomplete to work properly.
"moduleResolution": "bundler",
// JSX support
"jsx": "preserve",
"strict": true,
// Allow default imports.
"esModuleInterop": true,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"typeRoots": [
// This is needed to properly support Vitest testing with jest-dom matchers.
// Types for jest-dom are not recognized automatically and Typescript complains
// about missing types e.g. when using `toBeInTheDocument` and other matchers.
"node_modules/@testing-library",
// Specifying type roots overrides the default behavior of looking at the
// node_modules/@types folder so we had to list it explicitly.
// Source 1: https://www.typescriptlang.org/tsconfig#typeRoots
// Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843
"node_modules/@types"
],
// Since this TS config is used only for IDE support and not for
// compilation, the following directory doesn't exist. We need to specify
// it to prevent this error:
// https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file
"outDir": ".wasp/phantom"
}
}