Npm run serve Error

Majed Fayazi picture Majed Fayazi · Feb 27, 2018 · Viewed 14.1k times · Source

I have a problem with running the command : npm run serve

to fix it i need to logout or reboot my Ubuntu 16.04

I have checked the running tasks and node is not running.

I have also uninstalled node and npm and installed again with NVM but i still have the problem .

Npm error log :

>  [email protected] serve /home/work/work/git_repositories/xyz/ customer-frontend
> vue-cli-service serve --open

 INFO  Starting development server...
Starting type checking service...
Using 1 worker with 2048MB memory limit
 10% building modules 1/1 modules 0 activeevents.js:183                            
      throw er; // Unhandled 'error' event
      ^

Error: watch /home/work/work/git_repositories/xyz/customer-frontend/public ENOSPC
    at _errnoException (util.js:1022:11)
    at FSWatcher.start (fs.js:1374:19)
    at Object.fs.watch (fs.js:1400:11)
    at createFsWatchInstance (/home/work/work/git_repositories/xyz/customer-frontend/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/home/work/work/git_repositories/xyz/customer-frontend/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/work/work/git_repositories/xyz/customer-frontend/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:228:14)
    at FSWatcher.NodeFsHandler._handleDir (/home/work/work/git_repositories/xyz/customer-frontend/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:407:19)
    at FSWatcher.<anonymous> (/home/work/work/git_repositories/xyz/customer-frontend/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:455:19)
    at FSWatcher.<anonymous> (/home/work/work/git_repositories/xyz/customer-frontend/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:460:16)
    at FSReqWrap.oncomplete (fs.js:153:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR!  [email protected] serve: `vue-cli-service serve --open`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the s [email protected] serve 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/work/.npm/_logs/2018-02-27T11_40_39_880Z-debug.log

/home/work/.npm/_logs/2018-02-27T11_40_39_880Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/home/work/.nvm/versions/node/v8.9.4/bin/node',  
1 verbose cli   '/home/work/.nvm/versions/node/v8.9.4/bin/npm',
1 verbose cli   'run',
1 verbose cli   'serve' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
5 info lifecycle [email protected]~preserve: [email protected]
6 info lifecycle [email protected]~serve: [email protected]
7 verbose lifecycle [email protected]~serve: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~serve: PATH: /home/work/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/work/work/git_repositories/XYZ/customer-frontend/node_modules/.bin:/home/work/.nvm/versions/node/v8.9.4/bin:/home/work/bin:/home/work/.local/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 [email protected]~serve: CWD: /home/work/work/git_repositories/XYZ/customer-frontend
10 silly lifecycle [email protected]~serve: Args: [ '-c', 'vue-cli-service serve --open' ]
11 silly lifecycle [email protected]~serve: Returned: code: 1  signal: null
12 info lifecycle [email protected]~serve: Failed to exec serve script
13 verbose stack Error: [email protected] serve: `vue-cli-service serve --open`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/home/work/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285: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/work/.nvm/versions/node/v8.9.4/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:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/work/work/git_repositories/XYZ/customer-frontend
16 verbose Linux 4.13.0-36-generic
17 verbose argv "/home/work/.nvm/versions/node/v8.9.4/bin/node" "/home/work/.nvm/versions/node/v8.9.4/bin/npm" "run" "serve"
18 verbose node v8.9.4
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] serve: `vue-cli-service serve --open`
22 error Exit status 1
23 error Failed at the [email protected] serve script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

The project is based on Vuejs (typescript)

The thing is that i can run "npm run dev" without problem on other projects that are normal Vuejs (not typescript)

this is the Package.json

{
    "name": "xyz-customer-frontend",
    "version": "0.1.0",
    "private": true,
    "scripts": {
        "serve": "vue-cli-service serve --open",
        "build": "vue-cli-service build",
        "test": "vue-cli-service test",
        "e2e": "vue-cli-service e2e",
        "e2e:open": "vue-cli-service e2e:open"
    },
    "dependencies": {
        "axios": "^0.17.1",
        "buefy": "^0.6.3",
        "bulma": "^0.6.2",
        "echarts": "^4.0.2",
        "register-service-worker": "^1.0.0",
        "vue": "^2.5.13",
        "vue-class-component": "^6.0.0",
        "vue-property-decorator": "^6.0.0",
        "vue-router": "^3.0.1",
        "vuex": "^3.0.1",
        "vuex-class": "^0.3.0",
        "vuex-persistedstate": "^2.4.2"
    },
    "devDependencies": {
        "@types/chai": "^4.1.0",
        "@types/mocha": "^2.2.46",
        "@vue/cli-plugin-babel": "^3.0.0-beta.1",
        "@vue/cli-plugin-e2e-cypress": "^3.0.0-beta.1",
        "@vue/cli-plugin-pwa": "^3.0.0-beta.1",
        "@vue/cli-plugin-typescript": "^3.0.0-beta.1",
        "@vue/cli-plugin-unit-mocha": "^3.0.0-beta.1",
        "@vue/cli-service": "^3.0.0-beta.1",
        "@vue/test-utils": "^1.0.0-beta.10",
        "chai": "^4.1.2",
        "node-sass": "^4.7.2",
        "sass-loader": "^6.0.6",
        "vue-template-compiler": "^2.5.13"
    },
    "browserslist": [
        "> 1%",
        "last 2 versions",
        "not ie <= 8"
    ]
}

Node Version : v8.9.4

Npm Version : v5.6.0

Thanks for your time .

Answer

Majed Fayazi picture Majed Fayazi · Mar 7, 2018

Running this code have solved my problem on ubuntu 16.04

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p