AnswerBun.com

Ошибка при запуске webpack-dev-server

Stack Overflow на русском Asked by Voprositel on October 31, 2020

Только начал изучать webpack. При попытке запустить webpack-dev-server выдает ошибку:

‘webpack-dev-server’ is not recognized as an internal or external command,
operable program or batch file.

И далее:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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!     C:UsersUSERAppDataRoamingnpm-cache_logs2020-10-08T20_01_35_206Z-debug.log

Вот package.json:

{
    "name": "my",
    "version": "1.0.0",
    "description": "",
    "main": "app.js",
    "scripts": {
        "dev": "webpack-dev-server",
        "build": "webpack"
    },
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "webpack": "^4.44.2",
        "webpack-cli": "^3.3.12"
    }
}

И webpack.config.js:

const path = require('path');

module.exports = {
    entry: {
        app: './js/app.js'
    },
    context: path.resolve(__dirname, 'src'),
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist')
    },
    devServer: {
        publicPath: '/',
        port: 9000,
        contentBase: path.join(process.cwd(), 'dist'),
        host: 'localhost',
        historyApiFallback: true,
        noInfo: false,
        stats: 'minimal',
        hot: true,
    },
    mode: 'development'
}

Как решить данную проблему?

One Answer

Установите модуль для начала.

npm install webpack-dev-server --save-dev

И дальше по инструкции тут

Correct answer by Aziz Umarov on October 31, 2020

Add your own answers!

Related Questions

Модули в Python

1  Asked on December 2, 2020 by jey-jey

   

Правильный план для Cross DB views

1  Asked on December 1, 2020 by nick-proskuryakov

   

Проблема с Paging Library

0  Asked on December 1, 2020 by crush

     

Помогите с OpenCV

0  Asked on November 30, 2020

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP