Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In laravel npm run dev errors:

Tags:

I have next errors output running npm command for my laravel 5.6 with bootstrap project:

$ npm run dev  > @ dev /mnt/_work_sdb8/wwwroot/lar/B4test > npm run development   > @ development /mnt/_work_sdb8/wwwroot/lar/B4test > cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js  sh: 1: cross-env: not found npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn 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! spawn ENOENT 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!     /home/serge/.npm/_logs/2018-04-25T10_54_37_776Z-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!     /home/serge/.npm/_logs/2018-04-25T10_54_37_794Z-debug.log 

File /home/serge/.npm/_logs/2018-04-25T10_54_37_776Z-debug.log has:

0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'development' ] 2 info using [email protected] 3 info using [email protected] 4 verbose run-script [ 'predevelopment', 'development', 'postdevelopment' ] 5 info lifecycle @~predevelopment: @ 6 info lifecycle @~development: @ 7 verbose lifecycle @~development: unsafe-perm in lifecycle true 8 verbose lifecycle @~development: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/mnt/_work_sdb8/wwwroot/lar/B4test/node_modules/.bin:/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/mnt/_work_sdb8/wwwroot/lar/B4test/node_modules/.bin:/home/serge/.composer/vendor/bin:/home/serge/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:~/.composer/vendor/bin 9 verbose lifecycle @~development: CWD: /mnt/_work_sdb8/wwwroot/lar/B4test 10 silly lifecycle @~development: Args: [ '-c', 10 silly lifecycle   'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js' ] 11 info lifecycle @~development: Failed to exec development script 12 verbose stack Error: @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js` 12 verbose stack spawn ENOENT 12 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18) 12 verbose stack     at ChildProcess.emit (events.js:180:13) 12 verbose stack     at maybeClose (internal/child_process.js:936:16) 12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5) 13 verbose pkgid @ 14 verbose cwd /mnt/_work_sdb8/wwwroot/lar/B4test 15 verbose Linux 4.13.0-38-generic 16 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "development" 17 verbose node v9.11.1 18 verbose npm  v6.0.0 19 error file sh 20 error code ELIFECYCLE 21 error errno ENOENT 22 error syscall spawn 23 error @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js` 23 error spawn ENOENT 24 error Failed at the @ development script. 24 error This is probably not a problem with npm. There is likely additional logging output above. 25 verbose exit [ 1, true ] 

In composer.json :

{     "name": "laravel/laravel",     "description": "The Laravel Framework.",     "keywords": ["framework", "laravel"],     "license": "MIT",     "type": "project",     "require": {         "php": "^7.1.3",         "fideloper/proxy": "^4.0",         "laravel/framework": "5.6.*",         "components/highlightjs": "^9.12",         "doctrine/dbal": "^2.6",         "intervention/image": "^2.4",         "laracasts/utilities": "^3.0",         "laravel/tinker": "~1.0",         "nwidart/laravel-modules": "^3.0",         "pusher/pusher-php-server": "^3.0",         "spatie/laravel-backup": "^5.1",         "wboyz/laravel-enum": "^0.2.1"     },     "require-dev": {         "filp/whoops": "^2.0",         "fzaninotto/faker": "^1.7",         "mockery/mockery": "^1.0",         "nunomaduro/collision": "^2.0",         "phpunit/phpunit": "^7.0",         "barryvdh/laravel-debugbar": "^3.1",         "laravel/dusk": "~3.0"     },     "autoload": {         "classmap": [             "database/seeds",             "database/factories"         ],         "psr-4": {             "App\\": "app/",             "Modules\\": "Modules/"         }     },     "autoload-dev": {         "psr-4": {             "Tests\\": "tests/"         }     },     "extra": {         "laravel": {             "dont-discover": [             ]         }     },     "scripts": {         "post-root-package-install": [             "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""         ],         "post-create-project-cmd": [             "@php artisan key:generate"         ],         "post-autoload-dump": [             "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",             "@php artisan package:discover"         ]     },     "config": {         "preferred-install": "dist",         "sort-packages": true,         "optimize-autoloader": true     },     "minimum-stability": "dev",     "prefer-stable": true } 

In package.json :

{     "private": true,     "scripts": {         "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",         "watch": "npm run development -- --watch",         "watch-poll": "npm run watch -- --watch-poll",         "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",         "prod": "npm run production",         "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"     },     "devDependencies": {         "axios": "^0.18",         "bootstrap": "^4.0.0",         "popper.js": "^1.12",         "cross-env": "^5.1",         "jquery": "^3.2",         "laravel-mix": "^2.0",         "lodash": "^4.17.4",         "vue": "^2.5.7",         "vue-template-compiler": "^2.5.16",         "vue2-collapse": "^1.0.11"     },     "dependencies": {         "element-ui": "^2.3.6",         "font-awesome": "^4.7.0",         "fullcalendar": "^3.9.0",         "highlight.js": "^9.12.0",         "laravel-echo": "^1.3.5",         "marked": "^0.3.19",         "pusher-js": "^4.2.2",         "v-toaster": "^1.0.3",         "vee-validate": "^2.0.6",         "vee-validate-laravel": "^1.0.1",         "vue-bootstrap-datetimepicker": "^4.1.3",         "vue-chat-scroll": "^1.2.1",         "vue-fullcalendar": "^1.0.9",         "vue-js-popover": "^1.1.7",         "vue-moment": "^3.2.0",         "vue-mouse-menu": "^1.1.0",         "vue-nl2br": "0.0.5",         "vue-notify-me": "^1.1.0",         "vue-popperjs": "^1.2.6",         "vue-router": "^3.0.1",         "vue-select": "^2.4.0",         "vue-simple-calendar": "^2.2.0",         "vue-timeago": "^3.4.4",         "vuejs-datepicker": "^0.9.29"     } } 

Can you give a hint what could raize an error and how to fix it ?

Some error in config files or what?

Thank you very much!

like image 863
user2339232 Avatar asked Apr 25 '18 11:04

user2339232


People also ask

What is npm run Dev in Laravel?

In Laravel's case, the npm run dev command is an alias for the npm run development command. The development command is used to run the mix module, which is used to compile the JavaScript and CSS files written for the Laravel application.


2 Answers

You need to install the cross-env npm package.

npm install --save-dev cross-env 

It's listed in your dev dependencies, make sure to run npm install first.

like image 50
Brian Lee Avatar answered Oct 23 '22 11:10

Brian Lee


In my case I had to upgrade node to version 14.

Check your node version using

node -v 

And then, install a stable version from NODESOURCE

Basically,

# Using Ubuntu curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt-get install -y nodejs 

After this,

npm install 

Followed by the command as per your needs. In my case:

npm run dev 

In case you still face issues, try NPM ERROR

Just listing other keywords of this error:

npm ERR! @ development: mix

laravel npm ERR! code ELIFECYCLE laravel

error code ELIFECYCLE

npm ERR! Failed at the @ development script ERR! code EACCES

ERR! code ELIFECYCLE

ERR! code EMISSINGARG

like image 43
Reejesh PK Avatar answered Oct 23 '22 11:10

Reejesh PK