Framework: "npm run watch" generates error

Created on 24 Oct 2018  路  3Comments  路  Source: laravel/framework

  • Laravel Version: 5.7
  • PHP Version: PHP 7.2.10
  • Database Driver & Version: MySQL: mysql Ver 14.14 Distrib 5.7.24

When running npm run watch, I get the following error:

0 info it worked if it ends with ok 1 verbose cli [ '/home/$USER/.nvm/versions/node/v8.12.0/bin/node', 1 verbose cli '/home/$USER/.nvm/versions/node/v8.12.0/bin/npm', 1 verbose cli 'run', 1 verbose cli 'watch' ] 2 info using [email protected] 3 info using [email protected] 4 verbose run-script [ 'prewatch', 'watch', 'postwatch' ] 5 info lifecycle @~prewatch: @ 6 info lifecycle @~watch: @ 7 verbose lifecycle @~watch: unsafe-perm in lifecycle true 8 verbose lifecycle @~watch: PATH: /home/$USER/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/$PROJECT_NAME/node_modules/.bin:/home/$USER/.yarn/bin:/home/$USER/.nvm/versions/node/v8.12.0/bin:/home/$USER/.nvm:/home/$USER/.rbenv/plugins/ruby-build/bin:/home/$USER/.rbenv/shims:/home/$USER/.config/composer/vendor/bin:/home/$USER/.rbenv/bin:/home/$USER/.rbenv/plugins/ruby-build/bin:/home/$USER/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin 9 verbose lifecycle @~watch: CWD: /var/www/$PROJECT_NAME 10 silly lifecycle @~watch: Args: [ '-c', 'npm run development -- --watch' ] 11 silly lifecycle @~watch: Returned: code: 1 signal: null 12 info lifecycle @~watch: Failed to exec watch script 13 verbose stack Error: @ watch:npm run development -- --watch 13 verbose stack Exit status 1 13 verbose stack at EventEmitter.<anonymous> (/home/$USER/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16) 13 verbose stack at emitTwo (events.js:126:13) 13 verbose stack at EventEmitter.emit (events.js:214:7) 13 verbose stack at ChildProcess.<anonymous> (/home/$USER/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at emitTwo (events.js:126:13) 13 verbose stack at ChildProcess.emit (events.js:214:7) 13 verbose stack at maybeClose (internal/child_process.js:915:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 14 verbose pkgid @ 15 verbose cwd /var/www/$PROJECT_NAME 16 verbose Linux 4.18.0-10-generic 17 verbose argv "/home/$USER/.nvm/versions/node/v8.12.0/bin/node" "/home/$USER/.nvm/versions/node/v8.12.0/bin/npm" "run" "watch" 18 verbose node v8.12.0 19 verbose npm v6.4.1 20 error code ELIFECYCLE 21 error errno 1 22 error @ watch:npm run development -- --watch 22 error Exit status 1 23 error Failed at the @ watch script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

Steps To Reproduce:

  1. rm -rf node_modules
  2. npm install
  3. npm run dev (Completes successfully)
  4. npm run watch (Generates error above)

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.7.*", "laravel/tinker": "^1.0" }, "require-dev": { "beyondcode/laravel-dump-server": "^1.0", "filp/whoops": "^2.0", "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", "nunomaduro/collision": "^2.0", "phpunit/phpunit": "^7.0" }, "autoload": { "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\\": "app/" } }, "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 }
packge.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", "browser-sync": "^2.26.3", "browser-sync-webpack-plugin": "^2.2.2", "cross-env": "^5.1", "jquery": "^3.2", "laravel-mix": "^2.0", "lodash": "^4.17.5", "popper.js": "^1.12", "vue": "^2.5.7" } }

webpack.mix.js

`
const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
.sourceMaps()
.version()
.sass('resources/sass/app.scss', 'public/css')
.browserSync('dev.verticals.com');
`

Most helpful comment

@laidbackwebsage
Can you please try:

  • npm cache clean --force
  • rm -rf node_modules
  • npm install
  • npm run dev
  • npm run watch

Also what are your npm and node versions?

All 3 comments

@laidbackwebsage
Can you please try:

  • npm cache clean --force
  • rm -rf node_modules
  • npm install
  • npm run dev
  • npm run watch

Also what are your npm and node versions?

$ node -v
v8.12.0
$ npm -v
6.4.1

This worked, thank you very much!

My environment is;


1. Win-7 x64
2. PHP 7.1
3. Laravel 5.8

  1. I tried installing node.js from; https://nodejs.org/download/release/v10.14.2/
  2. Then check the version of node.js in cmd prompt, c:\Users\admin> node -v
  3. Then it comes to npm installation I tried installing from npm site https://www.npmjs.com/get-npm,
    copy the npm install npm@latest -g
  4. Then check the version using cmd prompt: c:\Users\admin> npm -v

after these steps,
I tried this command c:\xampp\htdocs\laravel> npm run watch (worked for me)

thank you
Let me know if it worked !!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shopblocks picture shopblocks  路  3Comments

YannPl picture YannPl  路  3Comments

ghost picture ghost  路  3Comments

jackmu95 picture jackmu95  路  3Comments

Anahkiasen picture Anahkiasen  路  3Comments