Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add jsconfig.json to existing vscode project w/o breaking it

I have React project, currently not using jsconfig.json file. Recently I got the following warning message, when generating a build (yarn):

Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.

I saw "local fixes" to add base_url here here, but I am afraid it will break my build in other places.

What is the safest way to fix this issue in an existing project? What additional settings are required in jsconfig.json? Or should I not worry at all and ignore it?

like image 931
Mulli Avatar asked Jun 04 '19 04:06

Mulli


People also ask

Where should I put Jsconfig json?

Place the file at the root of your JavaScript code as shown below. In more complex projects, you may have more than one jsconfig. json file defined inside a workspace. You will want to do this so that the code in one project is not suggested as IntelliSense to code in another project.


1 Answers

Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.

This is a warning stating that the method you use for the absolute path in your project i.e. adding NODE_PATH in your .env will be deprecated, in favor of setting baseUrl in either jsconfig.json or tsconfig.json

To fix this, you can add jsconfig.json or tsconfig.json in your root directory and set the baseUrl as src

{   "compilerOptions": {     "baseUrl": "./src"   } } 

Now remove NODE_PATH in your .env, this won't break anything in your current code and will remove the warning.

Note: paths in jsconfig or tsconfig is still not supported in CRA if you are planning to use this feature in your CRA project you have to wait

like image 182
saurabh Avatar answered Sep 29 '22 06:09

saurabh