TransWikia.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!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP