why I can not run npm run dev successfully in Laravel 7?

删除回忆录丶 提交于 2021-01-29 15:01:04

问题


Firstly, I installed a new Laravel 7 then,

npm install
npm run dev

I got these errors,

Again,

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]**

what can I do?

@ dev C:\Xampp\htdocs\my-task npm run development

@ development 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:


Update you nodejs version to the latest version.

via npm:

install -g n

or downloading & installing via website download page




回答2:


Try to update your nodejs version

npm install -g node

And then install cross-env globally

npm install --global cross-env

Finally install latest autoprefixer or 9.8.0 and run dev

npm install autoprefixer@9.8.0
npm install && run dev


来源:https://stackoverflow.com/questions/63085873/why-i-can-not-run-npm-run-dev-successfully-in-laravel-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!