{"record":{"id":"bd8d0987bc74ffbf","repo":"Meituan-Dianping/mpvue","slug":"webpack-config-target-should-be-node","errorCode":null,"errorMessage":"webpack config `target` should be \"node\".","messagePattern":"webpack config `target` should be \"node\"\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/server/webpack-plugin/util.js","lineNumber":9,"sourceCode":"const { red, yellow } = require('chalk')\n\nconst prefix = `[vue-server-renderer-webpack-plugin]`\nconst warn = exports.warn = msg => console.error(red(`${prefix} ${msg}\\n`))\nconst tip = exports.tip = msg => console.log(yellow(`${prefix} ${msg}\\n`))\n\nexport const validate = compiler => {\n  if (compiler.options.target !== 'node') {\n    warn('webpack config `target` should be \"node\".')\n  }\n\n  if (compiler.options.output && compiler.options.output.libraryTarget !== 'commonjs2') {\n    warn('webpack config `output.libraryTarget` should be \"commonjs2\".')\n  }\n\n  if (!compiler.options.externals) {\n    tip(\n      'It is recommended to externalize dependencies in the server build for ' +\n      'better build performance.'\n    )\n  }\n}\n\nexport { isJS, isCSS } from '../util'\n","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/src/server/webpack-plugin/util.js#L1-L25","documentation":"Emitted by the validate() check of the Vue SSR webpack plugin: it inspects the user's webpack compiler options and warns when compiler.options.target !== 'node'. The plugin's whole design (server bundle, manifest and externalized dependencies) assumes a Node-targeted server build; targeting 'web' produces a browser bundle that the server renderer cannot load, so this is a configuration sanity warning printed via chalk in red before the build proceeds.","triggerScenarios":"Thrown at src/server/webpack-plugin/util.js:9 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set target: 'node' in the webpack config used for the server bundle","Keep separate webpack configs for client (target: 'web') and server (target: 'node') entries","Point the VueSSRServerPlugin at the server config only, and verify the config object actually passed to webpack"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}