找不到模块:错误:无法解析“ ./src” laravel8

时间:2020-10-26 02:03:19

标签: php laravel webpack

我试图在我的根目录中运行npm run dev,但是出现此错误:

npm run dev

> 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

[webpack-cli] Unknown argument: --hide-modules
? Which flags do you want to use? ... 
√ Which flags do you want to use? · No items were selected
[webpack-cli]
Executing CLI

asset main.js 644 bytes [emitted] (name: main)

ERROR in main
Module not found: Error: Can't resolve './src' in 'C:\Users\xxxxx\Desktop\project'

webpack 5.2.0 compiled with 1 error in 56 ms
npm ERR! code 1
npm ERR! path C:\Users\xxxxxx\Desktop\project
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xxxxxx\AppData\Local\npm-cache\_logs\2020-10-26T01_53_38_098Z-debug.log
npm ERR! code 1
npm ERR! path C:\Users\xxxxxx\Desktop\project
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "npm run development"

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xxxxx\AppData\Local\npm-cache\_logs\2020-10-26T01_53_38_149Z-debug.log

我到处搜索过,但找不到解决方法!有什么想法吗?!?!

1 个答案:

答案 0 :(得分:0)

我在使用 Laravel 8.24.1 时遇到了同样的问题,我不得不将 webpack.config.js 移出 \app 文件夹。看到了来自这个 answer 的建议。