admin管理员组文章数量:1194549
I added a jsconfig.json
to my vscode project and for some reason I am getting a typescript error that states "dotenv/types
not found".
I cannot for the life of me figure out why I am getting this error. I even tried adding dotenv to my package.json
and it did not resolve my issue.
This is a standard project created with create-react-app, and I added the jsconfig.json
to allow absolute imports
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
Exception:
File '/Users/path/to/file/node_modules/dotenv/types' not found.
Other potential files that might be helpful:
package.json
{
"name": "quantous-spa",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.20.0",
"babel-plugin-macros": "^2.8.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-feather": "^2.0.8",
"react-loading-skeleton": "^2.1.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"styled-components": "^5.1.1",
"typeface-muli": "^1.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"prettier": "^2.0.5"
},
"resolutions": {
"styled-components": "^5"
}
}
.eslintrc
{
"env": {
"browser": true,
"es2020": true
},
"extends": [
"plugin:react/recommended",
"google",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"js": true
},
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": ["react"],
"rules": {
"require-jsdoc": "off"
},
"settings": {
"import/resolver": {
"node": {
"paths": ["node_modules", "src/"]
}
}
}
}
I added a jsconfig.json
to my vscode project and for some reason I am getting a typescript error that states "dotenv/types
not found".
I cannot for the life of me figure out why I am getting this error. I even tried adding dotenv to my package.json
and it did not resolve my issue.
This is a standard project created with create-react-app, and I added the jsconfig.json
to allow absolute imports
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
Exception:
File '/Users/path/to/file/node_modules/dotenv/types' not found.
Other potential files that might be helpful:
package.json
{
"name": "quantous-spa",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.20.0",
"babel-plugin-macros": "^2.8.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-feather": "^2.0.8",
"react-loading-skeleton": "^2.1.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"styled-components": "^5.1.1",
"typeface-muli": "^1.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"prettier": "^2.0.5"
},
"resolutions": {
"styled-components": "^5"
}
}
.eslintrc
{
"env": {
"browser": true,
"es2020": true
},
"extends": [
"plugin:react/recommended",
"google",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"js": true
},
"ecmaVersion": 11,
"sourceType": "module"
},
"plugins": ["react"],
"rules": {
"require-jsdoc": "off"
},
"settings": {
"import/resolver": {
"node": {
"paths": ["node_modules", "src/"]
}
}
}
}
Share
Improve this question
edited Apr 13, 2023 at 7:34
icc97
12.8k9 gold badges83 silver badges96 bronze badges
asked Aug 21, 2020 at 15:31
HJordan35HJordan35
2401 gold badge4 silver badges11 bronze badges
5
|
3 Answers
Reset to default 19If you're using Visual Studio Code, just disable "Typescript validation" in the settings.
The error should go away.
The @dioslibre answer works perfectly, but I didn't want to disable the Typescript validation. One alternative, explained by @Anees Hameed in their answer to a similar question is to add the following snippet to the settings.json:
"json.schemas": [
{
"$schema": "https://json.schemastore.org/jsconfig"
}
]
The error is telling you it can't find dotenv types. Run npm install dotenv
which installs types.
本文标签: javascriptSeeing unknown typescript error in JSConfigjson fileStack Overflow
版权声明:本文标题:javascript - Seeing unknown typescript error in JSConfig.json file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738476745a2088906.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
dotenv
had an open issue github.com/motdotla/dotenv/issues/475 that's generated a few SO questions – icc97 Commented Apr 12, 2023 at 17:56