Laravel 8 Vue 3-Npm运行热(混合观看-热)抛出错误,可能是网络包问题



编辑:可能是我的用户名有空格,所以webpack-cli在处理这种路径时遇到了问题吗?

我正试图用我的Laravel安装Vue 3,但由于某种原因,Laravel mix或webpack给我带来了错误,我试图卸载webpack和webpack-cli,然后再次安装它,但没有帮助。

Npm版本:6.14.6

包.json

{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"@types/webpack-env": "^1.16.0",
"@vue/compiler-sfc": "^3.0.6",
"axios": "^0.21",
"laravel-mix": "^6.0.0-beta.17",
"laravel-mix-vue3": "^0.7.0",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"vue": "^3.0.6",
"vue-loader": "^16.1.2",
"webpack": "^5.24.2",
"webpack-cli": "^4.5.0"
},
"dependencies": {}

Webpack.mix.js

const mix = require('laravel-mix');
require("laravel-mix-vue3");
mix.vue3("resources/js/app.js", "public/js")
.postCss('resources/css/app.css', 'public/css', [
//
]);

错误:

> mix watch --hot
[webpack-cli] Failed to load 'C:UsersPC' config
[webpack-cli] Error: Cannot find module 'C:UsersPC'
Require stack:
- C:UsersPC Master RaceDesktopLaravellearn-vuevue3testnode_moduleswebpack-clilibwebpack-cli.js
- C:UsersPC Master RaceDesktopLaravellearn-vuevue3testnode_moduleswebpack-clilibbootstrap.js
- C:UsersPC Master RaceDesktopLaravellearn-vuevue3testnode_moduleswebpack-clibincli.js
- C:UsersPC Master RaceDesktopLaravellearn-vuevue3testnode_moduleswebpackbinwebpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (C:UsersPC Master RaceDesktopLaravellearn-vuevue3testnode_modulesv8-compile-cachev8-compile-cache.js:159:20)
at loadConfig (C:UsersPC Master RaceDesktopLaravellearn-vuevue3testnode_moduleswebpack-clilibwebpack-cli.js:1158:31)
at C:UsersPC Master RaceDesktopLaravellearn-vuevue3testnode_moduleswebpack-clilibwebpack-cli.js:1245:74
at Array.map (<anonymous>)
at WebpackCLI.resolveConfig (C:UsersPC Master RaceDesktopLaravellearn-vuevue3testnode_moduleswebpack-clilibwebpack-cli.js:1245:32)
at WebpackCLI.createCompiler (C:UsersPC Master RaceDesktopLaravellearn-vuevue3testnode_moduleswebpack-clilibwebpack-cli.js:1670:33)
at Command.<anonymous> (C:UsersPC Master RaceDesktopLaravellearn-vuevue3testnode_modules@webpack-cliservelibindex.js:67:40) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\Users\PC Master Race\Desktop\Laravel\learn-vue\vue3test\node_modules\webpack-cli\lib\webpack-cli.js',
'C:\Users\PC Master Race\Desktop\Laravel\learn-vue\vue3test\node_modules\webpack-cli\lib\bootstrap.js',
'C:\Users\PC Master Race\Desktop\Laravel\learn-vue\vue3test\node_modules\webpack-cli\bin\cli.js',
'C:\Users\PC Master Race\Desktop\Laravel\learn-vue\vue3test\node_modules\webpack\bin\webpack.js'
]
}

经过数天数小时的搜索,我终于找到了答案。

这与你进入项目目录的方式有关。请参阅以下内容:

我用这种方式刻录到我的项目文件夹

cd C:/Repo/myproject/Laravel

这给了我上面的错误

但当我这样做的时候

cd C:/repo/myproject/laraavel

它起作用了,注意到文件夹名称的大小写很重要,它需要与您所称的文件夹完全匹配,显然它区分大小写。

祝你好运!

好吧,我的windows用户名似乎导致了这个错误,创建了一个用户名中没有空格的新帐户并且现在webpack-cli按预期工作,如果我理解错误右侧,webpack-cli可能会认为路径中有一个空格是路径的末尾

相关内容

  • 没有找到相关文章

最新更新