I created nest js project as following.
nest new project-name
and imported following from nuxt3 which is of type module
of node js with mjs
file extension (type definition of import doesn’t require to write mjs).
import { ViteBuildContext, ViteOptions, bundle } from '@nuxt/vite-builder-edge';
It gives me below error.
Uncaught Error Error [ERR_REQUIRE_ESM]: require() of ES Module c:UsersuserDocumentsGitLabdiscobitenode_modules@nuxtvite-builder-edgedistindex.mjs not supported. Instead change the require of c:UsersuserDocumentsGitLabprojectnode_modules@nuxtvite-builder-edgedistindex.mjs to a dynamic import() which is available in all CommonJS modules.
So I tried adding "type": "module"
in package.json so now I am getting below error.
Uncaught ReferenceError ReferenceError: exports is not defined in ES module scope This file is being treated as an ES module because it has a '.js' file extension and 'c:UsersuserDocumentsGitLabprojectpackage.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension. at <anonymous> (c:UsersuserDocumentsGitLabprojectdistmain.js:2:23)
How do I fix this? Error is related to typescript (or say compiled javascript) is unable to import mjs exports. What is solution to this?