Parsing tsconfig.json with support for extra commas
See original GitHub issuepackage.json
"dependencies": {
"ts-node": "^6.1.1",
"tsconfig-paths": "^3.4.0",
"typescript": "^2.9.2"
},
run command ts-node -r tsconfig-paths/register.js test.ts
C:\Users\Cat\Desktop\toy-ts-node\node_modules\tsconfig-paths\lib\tsconfig-loader.js:72
var config = JSON.parse(cleanedJson);
^
SyntaxError: Unexpected token } in JSON at position 305
at JSON.parse (<anonymous>)
at loadTsconfig (C:\Users\Cat\Desktop\toy-ts-node\node_modules\tsconfig-paths\lib\tsconfig-loader.js:72:23)
at loadSyncDefault (C:\Users\Cat\Desktop\toy-ts-node\node_modules\tsconfig-paths\lib\tsconfig-loader.js:27:18)
at tsConfigLoader (C:\Users\Cat\Desktop\toy-ts-node\node_modules\tsconfig-paths\lib\tsconfig-loader.js:13:22)
at Object.configLoader (C:\Users\Cat\Desktop\toy-ts-node\node_modules\tsconfig-paths\lib\config-loader.js:27:22)
at Object.register (C:\Users\Cat\Desktop\toy-ts-node\node_modules\tsconfig-paths\lib\register.js:10:46)
at Object.<anonymous> (C:\Users\Cat\Desktop\toy-ts-node\node_modules\tsconfig-paths\register.js:1:15)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
I really use the command
cross-env TS_NODE_PROJECT=./tool/tsconfig.json && ts-node -r tsconfig-paths/register ./node_modules/webpack/bin/webpack.js --config ./tool/config.webpack.dev.ts
cross-env TS_NODE_PROJECT=./tool/tsconfig.json && node -r tsconfig-paths/register webpack --config ./tool/config.webpack.dev.ts
I don’t know how to use it.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:16 (15 by maintainers)
Top Results From Across the Web
Can you use a trailing comma in a JSON object?
No. The JSON spec, as maintained at http://json.org, does not allow trailing commas. From what I've seen, some parsers may silently allow them...
Read more >tsconfig.json isn't strict JSON, what now? : r/typescript - Reddit
Any tools that are "doing it right" shouldn't be parsing the config file themselves, so I'd say go nuts with comments and trailing...
Read more >JSON - JavaScript - MDN Web Docs
The JSON object contains methods for parsing JavaScript Object Notation ... Property names must be double-quoted strings; trailing commas are forbidden.
Read more >JSON editing in Visual Studio Code
The mode also accepts trailing commas, but they are discouraged and the editor ... The JSON support shipped with VS Code supports all...
Read more >JSON with Commas and Comments - Hacker News
Anything with support for machine-readable schemas, validation, and robust ... ruby's JSON.parse accepts comments (but not trailing commas) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I know why.because my tsconfig.json uses jsonc. https://github.com/TypeStrong/ts-node/issues/409#issuecomment-398583581
But, tsc support jsonc. It would be better to have tsconfig-paths support jsonc.
@jonaskello done 🙂