我想我已经阅读了 SO 上的每个线程以及互联网上的每个相关页面,所有内容都有一些问题的变体
我想:
Node 14 据说支持 ESM,所以让我们使用它
设置1
我"type": "module"在我的package.json
然后我的webpack.config.js看起来像:
import { somethingUseful } from './src/js/useful-things.js';
export default (env, argv) => {
return {
// webpack config here
};
}
Run Code Online (Sandbox Code Playgroud)
运行> webpack(webpack-cli)我得到:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\git\Useroo\webpack.config.js
require() of ES modules is not supported.
require() of webpack.config.js from C:\nvm\v14.14.0\node_modules\webpack-cli\lib\groups\resolveConfig.js is an …Run Code Online (Sandbox Code Playgroud)