wazehaodeMBP:VUE-Test wazehao$ npm run dev
> vue-test@1.0.0 dev /Users/wazehao/code/VsCode/VUE-Test
> cross-env NODE_ENV=development webpack-dev-server --config webpack.config.js
/Users/wazehao/code/VsCode/VUE-Test/webpack.config.js:58
new webpack.DefinPlugin({
^
TypeError: webpack.DefinPlugin is not a constructor
at Object.<anonymous> (/Users/wazehao/code/VsCode/VUE-Test/webpack.config.js:58:9)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at WEBPACK_OPTIONS (/Users/wazehao/code/VsCode/VUE-Test/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13)
at requireConfig (/Users/wazehao/code/VsCode/VUE-Test/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6)
at /Users/wazehao/code/VsCode/VUE-Test/node_modules/webpack-cli/bin/utils/convert-argv.js:123:17
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-test@1.0.0 dev: `cross-env NODE_ENV=development webpack-dev-server --config webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-test@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/wazehao/.npm/_logs/2020-05-02T01_43_46_817Z-debug.log
我也报同样的错,和视频里代码一模一样,不知道怎么搞了?
new webpack.DefinPlugin => new webpack.DefinePlugin 少写个E
你是不是 只注意了 plugins里的配置,那你在页首 引入了 webpack 了吗? 需要提供代码,才能知道你具体的问题。
我也是同样的问题 webpack 也引入了 和老师的代码一样
根据你的报错来看,是webpack相关设置出了问题,可能是代码写错了。
webpack.config.js里面-plugins里面需要写以下:
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: isDev ? '"development"' : '"production"'
}
}),
同时最上面需要引入webpack
const webpack = require('webpack')