browser-sync-webpack-plugin not working

问题描述 投票:2回答:1

我已经按照https://www.npmjs.com/package/browser-sync-webpack-plugin的指示对其进行了配置>

这是我的webpack.config.js文件

const path = require('path');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');

const config = {
  mode: 'production',
  entry: './src/app.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js',
  },
  watch: true,
  plugins: [
    new BrowserSyncPlugin({
      host: 'localhost',
      port: 3000,
      server: {
        baseDir: ['dist']
      }
    })
  ]
}

module.exports = config;

package.json

{
  "name": "real-estate-2",
  "private": true,
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack --config webpack.config.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "browser-sync-webpack-plugin": "^2.2.2",
    "webpack": "^4.8.3",
    "webpack-cli": "^2.1.3"
  },
  "dependencies": {
    "lodash": "^4.17.10",
    "react": "^16.3.2",
    "react-dom": "^16.3.2"
  }
}

但是当我运行webpack时,在终端上出现此错误:错误:找不到模块“浏览器同步Webpack插件”

我已按照说明安装了browser-sync-webpack-plugin:npm install --save-dev browser-sync-webpack-plugin

我已经按照以下说明进行了配置:https://www.npmjs.com/package/browser-sync-webpack-plugin这是我的webpack.config.js文件const path = require('path'); const BrowserSyncPlugin = require('...

javascript node.js webpack browser-sync
1个回答
0
投票
npm install --save-dev browser-sync
© www.soinside.com 2019 - 2024. All rights reserved.