我已经使用导入/导出语法编写了 NodeJS JavaScript 文件,并且我的 package.json 有"type" : "module"
问题是tsc
构建代码后,转译的代码/build/server.js
无法运行。它说Exports is not defined in ES module scope
这是我的tsconfig.json
{
"compilerOptions": {
"resolveJsonModule": true,
"incremental": true,
"target": "es2019" ,
"module": : "commonjs",
"allowJs": true ,
"outDir": "./build",
"strict": true ,
"noImplicitAny": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true ,
"alwaysStrict": true ,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true ,
"inlineSourceMap": true ,
"experimentalDecorators": true,
"emitDecoratorMetadata": true ,
"forceConsistentCasingInFileNames": true, …
Run Code Online (Sandbox Code Playgroud) 我有一个网页,仅当用户使用他们的Spotify帐户登录后,我才希望该网页可供用户使用。我将Firebase用于后端。
我之前尚未实现任何社交身份验证,因此我们将非常感谢您提供深入的答案。
当我尝试使用 TypeScript 导入 mongoose 时,出现以下错误
node_modules/mongoose/node_modules/mongodb/mongodb.d.ts:3309:5 - error TS2416: Property 'end' in type 'GridFSBucketWriteStream' is not assignable to the same property in base type 'Writable'.
Run Code Online (Sandbox Code Playgroud)
显然这在 mongodb 4.3.0 中已修复,但 mongoose 使用 mongodb 4.2.2
我如何强制 mongoose 使用 mongodb 4.3.0+ ?
我尝试添加
"overrides": {
"mongoose": {
"mongodb": "^4.3.0"
}
},
Run Code Online (Sandbox Code Playgroud)
到 package.json 但它没有解决问题。
这是我的 package.json
{
"name": "reports",
"version": "1.0.0",
"type": "module",
"description": "",
"main": "index.js",
"engines": {
"node": "16.x"
},
"jest": {
"setupFiles": [
"<rootDir>/jestTestEnv.js"
]
},
"scripts": {
"test": "jest …
Run Code Online (Sandbox Code Playgroud)