You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and changed serverModuleFormat: "esm" in remix.config.js
the whole point is to have a top-level await in the db.server.ts file so when mongodb wants to connect it can do in a synchronous manner. also, it is interesting it is giving warnings for dotenv and MongoDB missing from the package.json as they are present and working properly although without the top-level await.
Expected Behavior
To work :D
Actual Behavior
[1] The path "dotenv" is imported in app\db.server.ts but dotenv is not listed in your package.json dependencies. Did you forget to install it?
[1] The path "mongodb" is imported in app\db.server.ts but mongodb is not listed in your package.json dependencies. Did you forget to install it?
[1]
[1] > app/db.server.ts:24:6: error: Top-level await is not available in the configured target environment ("es2021")
[1] 24 │ await global._mongoClient.connect();
[1] ╵ ~~~~~
[1] tsconfig.json:6:14: note: The target environment was set to "es2021" here
[1] 6 │ "target": "es2021",
The text was updated successfully, but these errors were encountered:
I was getting this error when running through the blog tutorial blog tutorial, seeding the db .
prisma/seed.ts:93:3 - error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.
I added your changes to the tsconfig.json and it's worked for me. Thanks.
What version of Remix are you using?
v1.1.1
What version of Node are you using? Minimum supported version is 14.
v16.13.1
Steps to Reproduce
Changed the tsconfig.json to allow top-level await
"module": "es2022", "lib": ["DOM", "DOM.Iterable", "ES2019"], "target": "es2021",
and changed
serverModuleFormat: "esm"
in remix.config.jsthe whole point is to have a top-level await in the db.server.ts file so when mongodb wants to connect it can do in a synchronous manner. also, it is interesting it is giving warnings for dotenv and MongoDB missing from the package.json as they are present and working properly although without the top-level await.
Expected Behavior
To work :D
Actual Behavior
[1] The path "dotenv" is imported in app\db.server.ts but dotenv is not listed in your package.json dependencies. Did you forget to install it?
[1] The path "mongodb" is imported in app\db.server.ts but mongodb is not listed in your package.json dependencies. Did you forget to install it?
[1]
[1] > app/db.server.ts:24:6: error: Top-level await is not available in the configured target environment ("es2021")
[1] 24 │ await global._mongoClient.connect();
[1] ╵ ~~~~~
[1] tsconfig.json:6:14: note: The target environment was set to "es2021" here
[1] 6 │ "target": "es2021",
The text was updated successfully, but these errors were encountered: