I'm studying the jsconfig.json file, the documentation doesn't mention explicitly whether it works with "import" and "require", or just "import".
This is the jsconfig.json I created (for Express project):
{
"compilerOptions": {
"baseUrl": "./",
"module": "CommonJS",
"target": "es2020",
"paths": {
"@/controllers/*": ["controllers/*"],
}
},
"exclude": ["node_modules", "**/node_modules/*"]
}
I can't do like this:
const userController = require('@/controllers/user-controller');
// Error: Cannot find module '@/controllers/user-controller'
Why can't I use "require"? I Tried it in React and it worked with "import".