//a.js let b=333; export {b}; //index.js import {b} from './a' //终端 node index.js
//终端提示 Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'E:\ThousandPhone\study\123\a' imported from E:\ThousandPhone\study\123\index.js Did you mean to import ../a.js? at finalizeResolution (internal/modules/esm/resolve.js:259:11) at moduleResolve (internal/modules/esm/resolve.js:636:10) at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:726:11) at Loader.resolve (internal/modules/esm/loader.js:97:40) at Loader.getModuleJob (internal/modules/esm/loader.js:243:28) at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:47:40) at link (internal/modules/esm/module_job.js:46:36) { code: 'ERR_MODULE_NOT_FOUND' }
from后面改成'./a.js'就能打印b,有办法像webpack那样不用加后缀直接'./a'就执行嘛?
标签:node,resolve,webapck,modules,js,internal,import,esm From: https://www.cnblogs.com/netflix/p/16800154.html