我正在尝试在Laravel项目上运行npm run dev
,但是出现以下错误:
Error: Cannot find module '/home/faramarz/todo/node_modules/laravel-mix/setup/
webpack.config.js'
是的,在节点模块目录中没有这样的文件。但是我没问题地跑了npm install
。
我还运行了npm i laravel-mix
,但没有安装它。
这是我的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": {
"axios": "^0.17",
"bootstrap-sass": "^3.3.7",
"cross-env": "^5.2.0",
"jquery": "^3.2",
"laravel-mix": "^1.0",
"lodash": "^4.17.4",
"vue": "^2.5.7"
}
}
我总是在运行此命令时遇到此问题。有帮助吗?
npm -v:6.4.1
答案 0 :(得分:6)
删除node_module目录并运行
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
在命令行中
如果这不起作用,请尝试
npm install webpack --save