小编Roo*_*ooz的帖子

TypeScript 和 NodeJS:ES 模块范围内未定义导出

我已经使用导入/导出语法编写了 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)

javascript node.js typescript

6
推荐指数
1
解决办法
5259
查看次数

如何使用Firebase进行“使用Spotify登录”身份验证系统?

我有一个网页,仅当用户使用他们的Spotify帐户登录后,我才希望该网页可供用户使用。我将Firebase用于后端。

我之前尚未实现任何社交身份验证,因此我们将非常感谢您提供深入的答案。

spotify asp.net-web-api firebase social-authentication

5
推荐指数
1
解决办法
1206
查看次数

如果已经安装了依赖项,则覆盖 package.json 中依赖项的 NPM 依赖项将不起作用

当我尝试使用 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)

node.js npm typescript package.json package-lock.json

5
推荐指数
1
解决办法
2万
查看次数