[Solved] npm run build missing script

We are facing these error on running the command npm run build

npm ERR! missing script: build

when adding a build in script section in package.json

"scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "npm run development -- --watch",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "build": "webpack-cli app.tsx --config webpack-config.js"

It tells webpack-config.js module not found my question is how to get webpack-cofig.js file in Laravel.

Solution #1:

You will need to create a webpack-config.js in the same folder as your package.json file. You can find a webpack-config.js structure here https://webpack.js.org/configuration/

Respondent: Hides

Solution #2:

As of Dec 2020

in the netlify build area, don’t say npm run build,

change it to CI= build configuration.

In the continuous integration area of a Netlify app this is the latest build command. Remember Netlify keep changing this, so check with the admin and call them up.

Respondent: Fioat N

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.