Почему при использовании
module.exports
у меня webpack работает правильно.
const path = require('path')
const config = {
entry:{
main:'./src/index.js'
},
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist')
}
}
module.exports = config
Но при использовании
export/import
в node.js
import path from 'path'
const config = {
entry:{
main:'./src/index.js'
},
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist')
}
}
export config
У меня вылазиет ошибка
[webpack-cli] Failed to load 'C:\Users\denis\Desktop\ASP\webpack.config.js' config
[webpack-cli] TypeError: Invalid host defined options
at eval (eval at dynamicImportLoader (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\utils\dynamic-import-loader.js:5:21), <anonymous>:3:1)
at loadConfig (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\webpack-cli.js:1346:41)
at WebpackCLI.resolveConfig (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\webpack-cli.js:1454:44)
at WebpackCLI.createCompiler (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\webpack-cli.js:1839:33)
at WebpackCLI.buildCommand (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\webpack-cli.js:1954:31)
at Command.<anonymous> (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\lib\webpack-cli.js:735:36)
at Command.listener [as _actionHandler] (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\node_modules\commander\index.js:922:31)
at Command._parseCommand (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\node_modules\commander\index.js:1503:14)
at Command._dispatchSubcommand (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\node_modules\commander\index.js:1443:18)
at Command._parseCommand (C:\Users\denis\Desktop\ASP\node_modules\webpack-cli\node_modules\commander\index.js:1460:12)
В
package.json
я ставлю "type": "module", но все равно не работает