为啥我不能在 Laravel 7 中成功运行 npm run dev?
Posted
技术标签:
【中文标题】为啥我不能在 Laravel 7 中成功运行 npm run dev?【英文标题】:why I can not run npm run dev successfully in Laravel 7?为什么我不能在 Laravel 7 中成功运行 npm run dev? 【发布时间】:2020-11-15 01:06:00 【问题描述】:首先,我安装了一个新的 Laravel 7 那么,
npm install
npm run dev
我收到了这些错误,
再次,
Removed node_modules, then npm install --global cross-env, followed by removing cross-env from package.json, then npm run dev, **[![but also not worked. same errors][1]][1]**
我能做什么?
@dev C:\Xampp\htdocs\my-task npm 运行开发
@开发 C:\Xampp\htdocs\my-task cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
C:\Xampp\htdocs\my-task\node_modules\webpack-cli\bin\cli.js:93
throw err;
^
Error: Package exports for 'C:\Xampp\htdocs\my-task\node_modules\colorette' do not define a valid '.' target
at resolveExportsTarget (internal/modules/cjs/loader.js:460:13)
at resolveExports (internal/modules/cjs/loader.js:393:16)
at Function.Module._findPath (internal/modules/cjs/loader.js:492:20)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:787:27)
at Function.Module._load (internal/modules/cjs/loader.js:693:27)
at Module.require (internal/modules/cjs/loader.js:864:19)
at require (C:\Xampp\htdocs\my-task\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
at Object.<anonymous> (C:\Xampp\htdocs\my-task\node_modules\autoprefixer\lib\autoprefixer.js:5:17)
at Module._compile (C:\Xampp\htdocs\my-task\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1011:10)
at Module.load (internal/modules/cjs/loader.js:822:32)
at Function.Module._load (internal/modules/cjs/loader.js:730:14)
at Module.require (internal/modules/cjs/loader.js:864:19)
at require (C:\Xampp\htdocs\my-task\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
at C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\components\Preprocessor.js:62:41
at C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\components\Preprocessor.js:69:31
at global.tap (C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\helpers.js:10:5)
at C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\components\Preprocessor.js:27:13
at Array.forEach (<anonymous>)
at Sass.webpackRules (C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\components\Preprocessor.js:22:22)
at ComponentFactory.applyRules (C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\components\ComponentFactory.js:155:23)
at C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\components\ComponentFactory.js:66:48
at C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\Dispatcher.js:34:47
at Array.forEach (<anonymous>)
at Dispatcher.fire (C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\Dispatcher.js:34:28)
at Mix.dispatch (C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\Mix.js:118:25)
at WebpackConfig.buildRules (C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\builder\WebpackConfig.js:90:13)
at WebpackConfig.build (C:\Xampp\htdocs\my-task\node_modules\laravel-mix\src\builder\WebpackConfig.js:23:14)
at Object.<anonymous> (C:\Xampp\htdocs\my-task\node_modules\laravel-mix\setup\webpack.config.js:29:38)
at Module._compile (C:\Xampp\htdocs\my-task\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1011:10)
at Module.load (internal/modules/cjs/loader.js:822:32)
at Function.Module._load (internal/modules/cjs/loader.js:730:14)
at Module.require (internal/modules/cjs/loader.js:864:19)
at require (C:\Xampp\htdocs\my-task\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
at WEBPACK_OPTIONS (C:\Xampp\htdocs\my-task\node_modules\webpack-cli\bin\utils\convert-argv.js:114:13)
code: 'MODULE_NOT_FOUND'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `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! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Dalin\AppData\Roaming\npm-cache\_logs\2020-07-25T07_35_17_515Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Dalin\AppData\Roaming\npm-cache\_logs\2020-07-25T07_35_17_535Z-debug.log
【问题讨论】:
【参考方案1】:将你的 nodejs 版本更新到最新版本。
通过 npm:
install -g n
或 downloading & installing via website download page
【讨论】:
npm install -g n【参考方案2】:尝试更新你的 nodejs 版本
npm install -g node
然后全局安装cross-env
npm install --global cross-env
最后安装最新的 autoprefixer 或 9.8.0 并运行 dev
npm install autoprefixer@9.8.0
npm install && run dev
【讨论】:
以上是关于为啥我不能在 Laravel 7 中成功运行 npm run dev?的主要内容,如果未能解决你的问题,请参考以下文章
为啥我不能使用 PHP artisan serve 运行我的 laravel 应用程序?
为啥我不能成功使用 composer require packageName?