SyntaxError: 意外的标记 ‘:’

huangapple go评论94阅读模式
英文:

SyntaxError: Unexpected token ':'

问题

I am using Node.js 18 and typescript.

我正在使用Node.js 18和TypeScript。

I builded my source of project and i got an error:

我构建了我的项目源代码,然后出现了一个错误:

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,
   

<details>
<summary>英文:</summary>

I am using Node.js 18 and typescript

I builded my source of project and i got an error:

```shell
C:\Users\user\Desktop\Work\blahblah\build\commands\information\help.js.map:1
{&quot;version&quot;:3,&quot;file&quot;:&quot;help.js&quot;,&quot;sourceRoot&quot;:&quot;&quot;,&quot;sources&quot;:[&quot;../../../src/commands/information/help.ts&quot;],&quot;names&quot;:[],&quot;mappings&quot;:&quot;;;;;;;;;;;;;;;;;;;;;;;;;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&quot;}
          ^

SyntaxError: Unexpected token &#39;:&#39;
    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

here is my tsconfig:

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

I will provide more information if you ask me

I tried:
Searching on google(didnt help)
Ask ChatGPT(didnt help also)

答案1

得分: 1

在“"mappings":”之后添加“{”。
代码将如下所示:

{ "version": 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EAAC,QAAQ,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" } }
英文:

add { after &quot;mappings&quot;:.
The code will be this :

{&quot;version&quot;:3,&quot;file&quot;:&quot;help.js&quot;,&quot;sourceRoot&quot;:&quot;&quot;,&quot;sources&quot;:[&quot;../../../src/commands/information/help.ts&quot;],&quot;names&quot;:[],&quot;mappings&quot;:{&quot;;;;;;;;;;;;;;;;;;;;;;;;;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,SAA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CAAoB,EAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;YACzF,UAAU,EAAE,CAAC,GAAU,CAAC;SACzB,CAAC,CAAC;IACL,CAAC;CACS,CAAA&quot;}

答案2

得分: 1

在tsconfig中禁用sourcemaps。

英文:

Disable sourcemaps in tsconfig.

huangapple
  • 本文由 发表于 2023年7月31日 21:56:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804340.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定