编写webpack配置文件后,再运行,持续不断的各种错误。好坑==。
npm run dev
webpackVue@1.0.0 dev /Users/webpackVue
webpack-dev-server --config webpack.config/dev.js
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
configuration.resolve has an unknown property 'fallback'. These properties are valid:
object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }configuration.resolve.extensions[0] should not be empty.
configuration.resolveLoader has an unknown property 'fallback'. These properties are valid:
object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v6.10.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! webpackVue@1.0.0 dev: webpack-dev-server --config webpack.config/dev.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpackVue@1.0.0 dev script 'webpack-dev-server --config webpack.config/dev.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webpackVue package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --config webpack.config/dev.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs webpackVue
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls webpackVue
npm ERR! There is likely additional logging output above.
如上报错,不知道是不是由于我还是webpack1.0版本太低导致的,还是其他原因。源码如下:
const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const baseConfig = require('./base')
const root = path.resolve(__dirname, '..')
module.exports = merge(baseConfig, {
entry: [
'webpack/hot/dev-server', // 热替换处理入口文件
path.join(root, 'src/main.js')
],
devServer: {
historyApiFallback: true, // 404的页面会自动跳转到/页面
inline: true, // 文件改变自动刷新页面
progress: true, // 显示编译进度
colors: true, // 使用颜色输出
port: 3000, // 服务器端口
},
devtool: 'source-map', // 用于标记编译后的文件与编译前的文件对应位置,便于调试
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: path.join(root, 'index.html'), // 模板文件
inject: 'body' // js的script注入到body底部
})
]
})
看过postcss也有类似的问题,但依旧不是很明确。求大神解答
你有没有用vue-cli,如果用这个了,你要是用npm run dev运行package.json中
需要这样配置的。
还有就是如果package.json中配置的对的话,可能是端口号被占用了,你可以改一下端口号