painterro icon indicating copy to clipboard operation
painterro copied to clipboard

[webpack-cli] Error: For the selected environment is no default script chunk format available

Open frifrafry opened this issue 3 years ago • 0 comments

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';
  }

frifrafry avatar Feb 24 '23 08:02 frifrafry