question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to load tsconfig.json: Missing baseUrl in compilerOptions

See original GitHub issue

No idea what’s going on here. My tsconfig.json:

project/tsonfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "module": "esnext",
    "removeComments": false,
    "sourceMap": true,
    "isolatedModules": false,
    "strictNullChecks": true,
    "target": "esnext",
    "moduleResolution": "node",
    "jsx": "react",
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "resolveJsonModule": true,
    "lib": ["dom", "esnext"],
    "baseUrl": ".",
    "paths": {
      "Audio/*": ["./app/assets/audios/*"],
      "Components/*": ["./app/assets/javascripts/components/*"],
      "Constants/*": ["./app/assets/javascripts/constants/*"],
      "Decorators/*": ["./app/assets/javascripts/components/decorators/*"],
      "Images/*": ["app/assets/images/*"],
      "Math/*": ["./app/assets/javascripts/math/*"],
      "Redux/*": ["./app/assets/javascripts/redux/*"],
      "Routes": ["./app/assets/javascripts/rails-routes.js.erb"],
      "Services/*": ["./app/assets/javascripts/services/*"],
      "Stylesheets/*": ["./app/assets/stylesheets/*"],
      "Types": ["./app/assets/javascripts/types/index"],
      "Utilities/*": ["./app/assets/javascripts/utilities/*"],
      "react": ["node_modules/@types/react"]
    },
    "preserveConstEnums": true
  },
  "include": [
    "app/assets/javascripts/**/*.ts",
    "app/assets/javascripts/**/*.tsx",
    "stories/**/*.ts",
    "stories/**/*.tsx"
  ],
  "exclude": ["node_modules"]
}

webpack.config.ts

// ...
  resolve: {
    plugins: [
      new TsconfigPathsPlugin({
        baseUrl: __dirname,
        extensions: [".js", ".ts", ".tsx"],
      }),
    ],
// ...

This error doesn’t make sense because, firstly, tsconfig.json has a baseUrl, and secondly, it doesn’t need one because I’ve included it in the options.

Also, this should kill the build rather than just logging. If it can’t find the file then what’s the point of continuing to run? The paths will not resolve.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:10
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

24reactions
bichikimcommented, Mar 29, 2019

I solve this problem by below code delete process.env.TS_NODE_PROJECT add this code on top of webapck.config.ts file.

👍

8reactions
kaankucukxcommented, May 13, 2019

Okey i got it to work.

I was in a hurry and i didn’t figured that i put my plugin initilization under resolve: {} property. I was configuring it under root plugin: [] property. So moving my configuration to resolve: {} fixes everything.

const config: webpack.Configuration = {
plugins: [],
resolve: [
 plugins: [
  new TsconfigPathsPlugin({
        configFile: path.resolve(__dirname, './tsconfig.json'),
        extensions: ['.ts', '.tsx', '.js'],
        logLevel: 'INFO',
        baseUrl: path.resolve(__dirname, '.'),
        mainFields: ['browser', 'main'],
      }),
]
],
}```
Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to load tsconfig.json: Missing baseUrl in compilerOptions
When I run in VS Code terminal npm start I get: react-scripts-ts start Failed to load tsconfig.json: Missing baseUrl in compilerOptions ...
Read more >
What is the baseUrl in compilerOptions used for? : r/typescript
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped. I am wondering if it's something I should have or not.
Read more >
compilerOptions.paths must not be set (alias imports are not ...
I've solved this issue by moving the baseUrl to the main tsconfig.json file like below: tsconfig: { "extends": "./tsconfig.paths.json", "compilerOptions": ...
Read more >
nrwl-nx/community - Gitter
Failed to load tsconfig.json : Missing baseUrl in compilerOptions Starting type checking service... Using 6 workers with 2048MB memory limit ...
Read more >
dividab - Bountysource
Failed to load tsconfig.json : Missing baseUrl in compilerOptions tsconfig-paths-webpack-plugin: Found no baseUrl in tsconfig.json, not applying ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found