背景
index.js:
import hello from './cpoy';
hello();
cpoy/index.js:
const hello = () => {
console.log("hello world!")
}
export default hello
在 package.json 中添加了"type": "module"配置。
报错
Directory import xxxx is not supported resolving ES modules imported from xxxx
解决
正确导入方式为import hello from './cpoy'/index.js,而不是import hello from './cpoy';不要忘了.js。
版权声明:本文为MrKorbin原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。