javascript 语法错误:意外的标记“:”

ruoxqz4g  于 2023-08-02  发布在  Java
关注(0)|答案(2)|浏览(170)

我正在使用Node.js 18和typescript
我构建了我的项目源代码,我得到了一个错误:

C:\Users\user\Desktop\Work\blahblah\build\commands\information\help.js.map:1
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/commands/information/help.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAMoB;AACpB,2CAAwF;AACxF,2DAA8D;AAG9D,uCAAyB;AACzB,+BAAmC;AAqBnC,iBAAS;IA
CP,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,2BAA2B;IACxC,IAAI,EAAE,IAAI,gCAAmB,EAAE;SAC1B,OAAO,CAAC,MAAM,CAAC;SACf,cAAc,CAAC,WAAI,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC;SACpD,2BAA2B,CAAC,IAAA,0BAAmB,EAAC,2BAA2B,CAAC,CAAC;SAC7E,eAAe,CAAC,MAAM,CAA
C,EAAE,CACtB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;SACpB,cAAc,CAAC,WAAI,CAAC,EAAE,CAAC,wCAAwC,CAAC,CAAC;SACjE,2BAA2B,CAAC,IAAA,0BAAmB,EAAC,wCAAwC,CAAC,CAAC,CAElG;IACL,OAAO,EAAE,KAAK,WAAU,GAAQ,EAAE,WAA+B;QAC/D,IAAI,YAAY,GAAG,EAAE,CAAA;QA
CrB,IAAI,oBAAoB,GAAG,EAAE,CAAA;QAE7B,IAAI,KAAK,GAAG,IAAI,CAAA;QAChB,KAAK,IAAI,WAAW,IAAI,EAAE,CAAC,WAAW,CAAC,IAAA,cAAO,EAAC,IAAA,WAAI,EAAC,SAAS,GAAC,kBAAkB,CAAC,CAAC,CAAC,EAAC;YAClF,IAAI,QAAQ,GAAG,OAAO,CAAC,kBAAkB,GAAE,WAAW,CAAC,
CAAA;YACvD,YAAY,CAAC,IAAI,CAAC,IAAI,0CAA6B,EAAE;iBAChD,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC;iBACjC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;iBACxB,QAAQ,CAAC,IAAA,gCAAyB,EAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;iBAClE,cAAc,CAAC,IAAA,gCAAyB,EAAC,QAA
Q,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;iBACnF,UAAU,CAAC,KAAK,CAAC,CACrB,CAAA;YACD,KAAK,GAAG,KAAK,CAAA;YACb,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;SACpC;QAED,MAAM,qBAAqB,GAAG,IAAI,oCAAuB,EAAE;aACtD,WAAW,CAAC,mBAAmB,CAAC;aAChC,UAAU,CAAC,
GAAG,YAAY,CAAC,CAAA;QAEhC,MAAM,GAAG,GAA0C,IAAI,6BAAgB,EAAE,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAA;QAE9G,MAAM,WAAW,CAAC,KAAK,CAAC;YACtB,MAAM,EAAE,CAAC,MAAM,IAAA,mCAAoB,EAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;YACzF,UAAU,EAAE,CAAC,GAAU,CAAC;SACzB,CAAC,CAAC;IACL,CAAC;CACS,CAAA"}
          ^

SyntaxError: Unexpected token ':'
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1176:20)
    at Module._compile (node:internal/modules/cjs/loader:1218:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at C:\Users\holybaechu\Desktop\Work\verico-discord-bot\build\events\registerCommands.js:49:170
    at async Object.execute (C:\Users\holybaechu\Desktop\Work\verico-discord-bot\build\events\registerCommands.js:49:34)

Node.js v18.16.0

字符串
下面是我的tsconfig:

{
  "compilerOptions": {
    "target": "es2017",
    "module": "commonjs",
    "lib": ["dom", "es6", "es2017", "esnext.asynciterable"],
    "skipLibCheck": true,
    "sourceMap": true,
    "outDir": "./build",
    "moduleResolution": "node",
    "removeComments": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "noUnusedParameters": false,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "allowSyntheticDefaultImports": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "resolveJsonModule": true,
    "baseUrl": ".",
    "esModuleInterop": true,
    "declaration": true,
    "declarationDir": "src/types"
  },
  "exclude": ["node_modules", "./src/types"],
  "include": ["./src", "./src/**/*.json"]
}


我会提供更多的信息,如果你问我
我试过:在谷歌上搜索(没有帮助)问ChatGPT(也没有帮助)

atmip9wb

atmip9wb1#

"mappings":之后添加{
代码如下:

{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/commands/information/help.ts"],"names":[],"mappings":{";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAMoB;AACpB,2CAAwF;AACxF,2DAA8D;AAG9D,uCAAyB;AACzB,+BAAmC;AAqBnC,iBAAS;IA
CP,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,2BAA2B;IACxC,IAAI,EAAE,IAAI,gCAAmB,EAAE;SAC1B,OAAO,CAAC,MAAM,CAAC;SACf,cAAc,CAAC,WAAI,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC;SACpD,2BAA2B,CAAC,IAAA,0BAAmB,EAAC,2BAA2B,CAAC,CAAC;SAC7E,eAAe,CAAC,MAAM,CAA
C,EAAE,CACtB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;SACpB,cAAc,CAAC,WAAI,CAAC,EAAE,CAAC,wCAAwC,CAAC,CAAC;SACjE,2BAA2B,CAAC,IAAA,0BAAmB,EAAC,wCAAw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