Im trying to import modules from directory and catching the error.
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import 'C:\js\tg_bot\constants' is not supported resolving ES modules imported from C:\js\tg_bot\index.js
Did you mean to import ../constants/index.js?
package.json
{
"name": "tgbot",
"type": "module",
"private": true,
"scripts": {
"start": "nodemon index.js"
},
"dependencies": {
"@grammyjs/menu": "^1.0.4",
"dotenv": "^16.0.0",
"grammy": "^1.7.0",
"telegraf": "^4.7.0",
"telegram-bot-api": "^2.0.1"
}
}
index.js
import {MSGS, KEYBOARD} from './constants';
console.log(MSGS)
constants/index.js
export { default as KEYBOARD } from './KEYBOARDS';
export { default as MSGS } from './MSGS';
constants/MSGS.js
export const MSGS = {
START: 'My msg'
}
export default MSGS
command
node index.js
file structure:
/constants/index.js
/constants/KEYBOARD.js
/constants/MSGS.js
/index.js
...
I have some ideas about babel but havent ever used it. In React project built with create-react-app everything works perfect. Any help please)