部署nodejs环境碰到的一些坑,[nodemon] Internal watch failed: watch /usr/src/app/app ENOSPC

启动node的时候出现如下提升:

[nodemon] Internal watch failed: watch /usr/src/app/app ENOSPC

解决办法是在终端输入如下命令,然后重新运行

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

或者

sudo sysctl fs.inotify.max_user_watches=582222 && sudo sysctl -p

该命令行的意思是将系统当前用户下允许监视的文件数量增加到一定数值。默认情况下该值比较低,而nodemon往往会监视大量的文件和目录,所以我们需要通过这行命令来修改这个值。

> [email protected] test2 /usr/src/app
> NODE_ENV=test2 DEBUG=1 SWAGGER=online nodemon --exec babel-node --harmony app/server.js

[nodemon] 1.18.11
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /usr/src/app/app/**/* webpack.config.js webpack server.js server_old.js server_new.js server_old_dev.js webpack.config.prod.js webpack.config.prod.dev.js
[nodemon] starting `babel-node --harmony app/server.js`
[nodemon] Internal watch failed: watch /usr/src/app/app ENOSPC

npm ERR! Linux 3.10.0-514.el7.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test2"
npm ERR! node v6.17.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test2: `NODE_ENV=test2 DEBUG=1 SWAGGER=online nodemon --exec babel-node --harmony app/server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test2 script 'NODE_ENV=test2 DEBUG=1 SWAGGER=online nodemon --exec babel-node --harmony app/server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-antd-hrm package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=test2 DEBUG=1 SWAGGER=online nodemon --exec babel-node --harmony app/server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs react-antd-hrm
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls react-antd-hrm
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/src/app/npm-debug.log

你可能感兴趣的:(nodejs)