英文:
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
{"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
here is my 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"]
}
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": 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;IACP,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,CAAC,EAAE,CACtB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;SACpB,cAAc,CAAC,WAAI,CAAC,EAAE,CAAC,wCAAwC,CAAC,CAAC;SACjE,2BAA2B,C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,CAAC,GAAU,CAAC;SACzB,CAAC,CAAC;IACL,CAAC;CACS,CAAA" } }
英文:
add {
after "mappings":
.
The code will be this :
{"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"}
答案2
得分: 1
在tsconfig中禁用sourcemaps。
英文:
Disable sourcemaps in tsconfig.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论