[英]absolute path not working in my react project?
我在 react 上使用最新版本。我创建了 react 项目然后意识到相对路径不适用于可扩展项目,所以我创建了 jsconfig.json 文件然后尝试导入绝对路径但不起作用。 jsconfig.json
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"*": [
"src/*"
]
}
}
}
错误
/src/Components/AllImportFiles/ImportPng.jsx
找不到模块:无法解析“/Users/apple/Desktop/Driveu_Folder/src/Components/AllImportFiles”中的“Assets/Images/Car Maintanance IMage Mobile.png”
Uncaught Error: Cannot find module 'Assets/Images/cnbc18.png'
at webpackMissingModule (ImportPng.jsx:1:1)
at ./src/Components/AllImportFiles/ImportPng.jsx (ImportPng.jsx:1:1)
at __webpack_require__ (bootstrap:787:1)
at fn (bootstrap:150:1)
at ./src/Components/BuyAndSell/BuyAndSell.jsx (BuyAndSell.css?c9ef:45:1)
at __webpack_require__ (bootstrap:787:1)
at fn (bootstrap:150:1)
at ./src/Components/Pages/HomePage.jsx (NewsFeed.jsx:78:1)
at __webpack_require__ (bootstrap:787:1)
at fn (bootstrap:150:1)
at ./src/App.js (App.css?da7c:45:1)
at __webpack_require__ (bootstrap:787:1)
at fn (bootstrap:150:1)
at ./src/index.js (index.css?02e3:45:1)
at __webpack_require__ (bootstrap:787:1)
at fn (bootstrap:150:1)
at 0 (reportWebVitals.js:13:1)
at __webpack_require__ (bootstrap:787:1)
at checkDeferredModules (bootstrap:45:1)
at Array.webpackJsonpCallback [as push] (bootstrap:32:1)
at main.chunk.js:1:57
和其他错误也喜欢
webpackMissingModule @ ImportPng.jsx:1
./src/Components/AllImportFiles/ImportPng.jsx @ ImportPng.jsx:1
__webpack_require__ @ bootstrap:787
fn @ bootstrap:150
./src/Components/BuyAndSell/BuyAndSell.jsx @ BuyAndSell.css?c9ef:45
__webpack_require__ @ bootstrap:787
fn @ bootstrap:150
./src/Components/Pages/HomePage.jsx @ NewsFeed.jsx:78
__webpack_require__ @ bootstrap:787
fn @ bootstrap:150
./src/App.js @ App.css?da7c:45.
__webpack_require__ @ bootstrap:787
fn @ bootstrap:150
(anonymous) @ main.chunk.js:1
index.js:1437 ./src/Components/AllImportFiles/ImportPng.jsx
Module not found: Can't resolve 'Assets/Images/Car Maintanance IMage Mobile.png' in
'/Users/apple/Desktop/Driveu_Folder/src/Components/AllImportFiles'
console.<computed> @ index.js:1437
overrideMethod @ react_devtools_backend.js:4026
handleErrors @ webpackHotDevClient.js:156
push../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @
webpackHotDevClient.js:193
push../node_modules/sockjs-client/lib/event/eventtarget.js.EventTarget.dispatchEvent
@ eventtarget.js:56
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.