这在用户界面级别上没有问题:
import profileImg from '../../assets/murdoch.jpg';
但是我在VSCode上收到此错误:
找不到模块'../../ assets / murdoch.jpg'.ts(2307)
这在UI和VSCode上都没有问题:
const profileImg = require('../../assets/murdoch.jpg');
但是我想导入它,因为测试未通过
SyntaxError: Invalid or unexpected token
3 | import ProfilePicture from './ProfilePicture';
4 |
> 5 | const profileImg = require('../../assets/murdoch.jpg');
这是我的tsconfig.json
{
"compilerOptions": {
"sourceMap": true,
"noImplicitAny": false,
"module": "commonjs",
"removeComments": true,
"baseUrl": "./",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": false,
"jsx": "react",
"lib": ["es6", "dom"],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext"
},
"exclude": ["node_modules", "jest.config.js", "webpack.config.js"]
}
我想念什么?
编辑:
项目树