webpack.js is not found in laravel vue app?

不问归期 提交于 2020-12-15 05:20:17

问题


i am using vue in laravel and trying run npm run dev but it is giving me this error

 code: 'MODULE_NOT_FOUND',
  requireStack: [
    'G:\\laravel-vuetify-spa-starter\\node_modules\\webpack-cli\\bin\\utils\\convert-argv.js',
    'G:\\laravel-vuetify-spa-starter\\node_modules\\webpack-cli\\bin\\cli.js',
    'G:\\laravel-vuetify-spa-starter\\node_modules\\webpack\\bin\\webpack.js'
  ]


npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpa
ck.config.js`

Package.json

{
  "private": true,
  "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": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "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"
  },
  "devDependencies": {
    "@babel/core": "^7.11.1",
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
    "@babel/preset-env": "^7.11.0",
    "@babel/preset-react": "^7.0.0",
    "and": "0.0.3",
    "babel-cli": "^6.26.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-loader": "^7.1.5",
    "babel-preset-env": "^1.7.0",
    "eslint": "^5.9.0",
    "install": "^0.12.2",
    "jest": "^23.6.0",
    "npm": "^6.4.1",
    "sass": "^1.26.10",
    "sass-loader": "^7.3.1",
    "vue": "^2.6.11",
    "vue-router": "^3.4.3",
    "vue-template-compiler": "^2.6.11",
    "vuetify": "^2.3.9",
    "vuetify-loader": "^1.4.3",
    "vuetify-toast-snackbar": "^0.6.1",
    "vuex": "^3.5.1",
    "webpack": "^4.44.1",
    "webpack-cli": "^3.3.12"
  },
  "dependencies": {
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "cross-env": "^7.0.2",
    "css-loader": "^1.0.1",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.11.0",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "resolve-url-loader": "^3.0.0",
    "sass-loader": "^7.1.0",
    "webpack-dev-server": "^3.1.10"
  }
}


How i can solve this issue ?


回答1:


The development script in your package.json is attempting to load the webpack config from laravel-mix and you don't have it installed

"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules 
--config=node_modules/laravel-mix/setup/webpack.config.js",

Just install laravel-mix or create your own webpack config

npm i laravel-mix

And make sure that you have webpack.mix.js on the root directory if you decide to use the mix wrapper

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');


来源:https://stackoverflow.com/questions/63489559/webpack-js-is-not-found-in-laravel-vue-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!