不知道发生了什么,但我真的坚持这个。
问题是当我运行 npm run prod
或 npm run dev
时,我面临以下错误:
> prod
> npm run production
> production
> mix --production
[webpack-cli] ReferenceError: navigator is not defined
at \\\\\\path_of_my_project\\\\\\\\webpack.mix.js:26:390
at Object.<anonymous> (\\\\\\path_of_my_project\\\\\\\\webpack.mix.js:26:780)
at Module._compile (\\\\\\path_of_my_project\\\\\\\\node_modules\v8-compile-cache\v8-compile-c
ache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (\\\\\\path_of_my_project\\\\\\\\node_modules\v8-compile-cache\v8-compile-cache.js:
159:20)
at module.exports (\\\\\\path_of_my_project\\\\\\\\node_modules\laravel-mix\setup\webpack.conf
ig.js:8:5)
at \\\\\\path_of_my_project\\\\\\\\node_modules\webpack-cli\lib\webpack-cli.js:1565:43
这就是我在 npm audit
上发现的:-
>npm audit
# npm audit report
css-what <5.0.1
Severity: high
Denial of Service - https://npmjs.com/advisories/1754
fix available via `npm audit fix --force`
Will install laravel-mix@5.0.9, which is a breaking change
node_modules/css-what
css-select <=3.1.2
Depends on vulnerable versions of css-what
node_modules/css-select
svgo >=1.0.0
Depends on vulnerable versions of css-select
node_modules/svgo
postcss-svgo >=4.0.0-nightly.2020.1.9
Depends on vulnerable versions of svgo
node_modules/postcss-svgo
cssnano-preset-default *
Depends on vulnerable versions of postcss-svgo
node_modules/cssnano-preset-default
cssnano >=4.0.0-nightly.2020.1.9
Depends on vulnerable versions of cssnano-preset-default
node_modules/cssnano
laravel-mix 5.0.8 || >=6.0.0-alpha.0
Depends on vulnerable versions of cssnano
node_modules/laravel-mix
7 high severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
这是我的 package.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": {
"axios": "^0.21.1",
"bootstrap": "^4.5.3",
"browser-sync": "^2.26.12",
"browser-sync-webpack-plugin": "^2.2.2",
"cross-env": "^7.0.2",
"jquery": "^3.5.1",
"jquery-scroll-lock": "^3.1.3",
"jquery.appear": "^1.0.1",
"js-cookie": "^2.2.1",
"laravel-echo": "^1.9.0",
"laravel-mix": "^6.0.25",
"lodash": "^4.17.20",
"popper.js": "^1.16.1",
"pusher-js": "^7.0.0",
"resolve-url-loader": "^3.1.0",
"sass": "^1.27.0",
"sass-loader": "^10.0.3",
"simplebar": "^5.2.1",
"sweetalert2": "^10.6.1",
"vue": "^2.6.12",
"vue-template-compiler": "^2.6.12"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.1",
"magnific-popup": "^1.1.0",
"request": "2.88.2"
}
}
我只尝试清除缓存 npm cache clean --force
但什么也没发生。
**我的 npm 版本是:7.16.0,Laravel 版本是:"^8.0" **