[webpack-cli] Error: For the selected environment is no default script chunk format available
frifrafry opened this issue · 2 comments
frifrafry commented
I had a problem building painterro 'commonjs2', 'amd' and 'umd' in production lately.
Environment:
npm 8.1.2
webpack-cli 4.9.2
painterro 1.2.78
Windows 10 Pro (21H2)
Error Message:
JSONP Array push can be chosen when 'document' or 'importScripts' is available.
CommonJs exports can be chosen when 'require' or node builtins are available.
Select an appropriate 'target' to allow selecting one by default, or specify the 'output.chunkFormat' directly.
at E:\painterro\node_modules\webpack\lib\config\defaults.js:814:11
at F (E:\painterro\node_modules\webpack\lib\config\defaults.js:73:15)
at applyOutputDefaults (E:\painterro\node_modules\webpack\lib\config\defaults.js:795:2)
at applyWebpackOptionsDefaults (E:\painterro\node_modules\webpack\lib\config\defaults.js:196:2)
at createCompiler (E:\painterro\node_modules\webpack\lib\webpack.js:77:2)
at E:\painterro\node_modules\webpack\lib\webpack.js:44:48
at Array.map (<anonymous>)
at createMultiCompiler (E:\painterro\node_modules\webpack\lib\webpack.js:44:33)
at create (E:\painterro\node_modules\webpack\lib\webpack.js:125:16)
at webpack (E:\painterro\node_modules\webpack\lib\webpack.js:142:47)
Temporary Work-Around for 'commonjs2':
Changing target
for 'commonjs2' in webpack.config.js
from es2020
to browserslist
(insert in line 74):
} else if (target === 'commonjs2') {
options.target = 'browserslist';
} else {
options.target = 'es2020';
}
ivictbor commented
@frifrafry did you resolve the issue? I think it might be related to nodejs version, which one do you use?
ivictbor commented
Please follow a readme https://github.com/devforth/painterro?tab=readme-ov-file#development-