7

我在运行命令时遇到问题:npm run serve

要修复它,我需要注销或重新启动我的 Ubuntu 16.04

我检查了正在运行的任务并且节点没有运行。

我还卸载了 node 和 npm 并再次使用 NVM 安装,但我仍然有问题。

Npm 错误日志:

>  customer-frontend@0.1.0 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!  customer-frontend@0.1.0 serve: `vue-cli-service serve --open`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the s customer-frontend@0.1.0 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 npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
5 info lifecycle customer-frontend@0.1.0~preserve: customer-frontend@0.1.0
6 info lifecycle customer-frontend@0.1.0~serve: customer-frontend@0.1.0
7 verbose lifecycle customer-frontend@0.1.0~serve: unsafe-perm in lifecycle true
8 verbose lifecycle customer-frontend@0.1.0~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 customer-frontend@0.1.0~serve: CWD: /home/work/work/git_repositories/XYZ/customer-frontend
10 silly lifecycle customer-frontend@0.1.0~serve: Args: [ '-c', 'vue-cli-service serve --open' ]
11 silly lifecycle customer-frontend@0.1.0~serve: Returned: code: 1  signal: null
12 info lifecycle customer-frontend@0.1.0~serve: Failed to exec serve script
13 verbose stack Error: customer-frontend@0.1.0 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 customer-frontend@0.1.0
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 customer-frontend@0.1.0 serve: `vue-cli-service serve --open`
22 error Exit status 1
23 error Failed at the customer-frontend@0.1.0 serve script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

该项目基于Vuejs(打字稿)

问题是我可以在其他普通 Vuejs(不是打字稿)的项目上毫无问题地运行“npm run dev”

这是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"
    ]
}

节点版本:v8.9.4

Npm 版本:v5.6.0

谢谢你的时间 。

4

3 回答 3

20

运行此代码解决了我在 ubuntu 16.04 上的问题

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
于 2018-03-07T09:23:33.157 回答
10

老实说,我不知道为什么会发生此错误!

但是,一旦我sudo在终端中对其进行了测试,它就起作用了:

sudo npm run serve

或者,为了开发:

sudo npm run dev
于 2018-10-20T08:59:47.457 回答
0

如果您在运行命令时遇到问题,npm run serve而不仅仅是从项目中删除“node_modules”文件夹并运行命令npm i,或者npm install只运行任何命令。此命令将再次安装您的“node_modules”文件夹并具有新的良好依赖项,现在您可以使用命令 npm run serve 谢谢

于 2022-02-27T02:58:59.637 回答