Javascript Node.JS:获取错误:[nodemon] 内部监视失败:监视 ENOSPC
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34662574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Node.JS: Getting error : [nodemon] Internal watch failed: watch ENOSPC
提问by Erik ?sland
I just installed Node.js
on my Ubuntu 14.04
operating system for the first time. I also installed npm
. The next step in my installation process was installing nodemon
. This all worked out fine.
我第一次安装Node.js
在我的Ubuntu 14.04
操作系统上。我也安装了npm
。我安装过程的下一步是安装nodemon
. 这一切都很好。
But, when I run nodemon
by typing nodemon app.js
in my command line, I get the following error...
但是,当我nodemon
通过nodemon app.js
在命令行中键入来运行时,出现以下错误...
[nodemon] 1.8.1
[nodemon] to restart at any time, enter
rs[nodemon] watching: *.*
[nodemon] starting
node app.js[nodemon] Internal watch failed: watch ENOSPC
[nodemon] 1.8.1
[nodemon] to restart at any time, enter
rs[nodemon] watching: *.*
[nodemon] starting
节点app.js[nodemon] Internal watch failed: watch ENOSPC
In the command line below the error...
在错误下方的命令行中...
alopex@Alopex:~/Desktop/coding_dojo/week-9/javascript/node/testing_node$ Hello World
Why is this happening? Is this normal behavior for nodemon? If not, how can I fix it?
为什么会这样?这是 nodemon 的正常行为吗?如果没有,我该如何解决?
Side notes...
旁注...
1) app.js
is a Javascript
file with console.log(111)
inside of it.
2) node
version is v0.10.25
3) npm
version is 1.3.10
4) nodemon
version is 1.8.1
5) ubuntu
version is...
1)app.js
是一个Javascript
包含console.log(111)
在其中的文件。
2)node
版本是v0.10.25
3)npm
版本是1.3.10
4)nodemon
版本是1.8.1
5)ubuntu
版本是...
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
回答by Erik ?sland
It appears that my max ports weren't configured correctly. I ran the following code and it worked...
看来我的最大端口没有正确配置。我运行了以下代码,它起作用了......
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
What this command does is to increase the number of watches allowed for a single user. By the default the number can be low (8192 for example). When nodemon
tries to watch large numbers of directories for changes it has to create several watches, which can surpass that limit.
此命令的作用是增加单个用户允许的监视数量。默认情况下,该数字可能很小(例如 8192)。当nodemon
尝试查看大量目录的更改时,它必须创建多个可以超过该限制的监视。
You could also solve this problem by:
您还可以通过以下方式解决此问题:
sudo sysctl fs.inotify.max_user_watches=582222 && sudo sysctl -p
But the way it was written first will make this change permanent.
但是它最初的编写方式将使这种更改永久化。
回答by pawanpandey392
Erik, You can just kill all the other node processes by
Erik,您可以通过以下方式杀死所有其他节点进程
pkill -f node
pkill -f 节点
and then restart your server again. It'll work just fine then.
然后再次重新启动您的服务器。那时它会工作得很好。
回答by Mani Abi Anand
On running node server shows Following Errors and solutions:
在运行节点服务器上显示以下错误和解决方案:
nodemon server.js
nodemon server.js
[nodemon] 1.17.2
[nodemon] to restart at any time, enter
rs
[nodemon] watching: .
[nodemon] starting
node server.js
[节点] 1.17.2
[nodemon] 随时重启,输入
rs
[nodemon] 观看:。
[nodemon] 开始
node server.js
[nodemon] Internal watch failed: watch /home/aurum304/jin ENOSPC
[nodemon] 内部监听失败:watch /home/aurum304/jin ENOSPC
sudo pkill -f node
or
或者
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
回答by Zubair Alam
As per discussion over here, ENOSPC
means Error No more hard-disk space available
. Reason why this much memory required by nodemon
or gulp-nodemon
(in my case) is that it was watching contents of a folder which it shouldn't. To fix that nodemon has ignore
setting that can be used to tell nodemon what not to watch. Have a look at nodemon sample config here.
根据这里的讨论,ENOSPC
意思是Error No more hard-disk space available
。nodemon
or gulp-nodemon
(在我的情况下)需要这么多内存的原因是它正在观看它不应该看到的文件夹的内容。要修复该 nodemon 具有ignore
可用于告诉 nodemon 什么不该看的设置。在这里查看 nodemon 示例配置。
回答by codeinaire
[nodemon] Internal watch failed: watch /home/Document/nmmExpressServer/bin ENOSPC
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `nodemon ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
This is the error I got when running nodemon ./bin/www
.
这是我运行时遇到的错误nodemon ./bin/www
。
The solution was closing an Atom windowthat had a entire directory of folders open in the project window.
解决方案是关闭一个 Atom 窗口,该窗口在项目窗口中打开了整个文件夹目录。
I don't know why, but I'm assuming Atom and nodemon use similar processes to watch files/folders.
我不知道为什么,但我假设 Atom 和 nodemon 使用类似的过程来监视文件/文件夹。
回答by MD SHAYON
Try this....
尝试这个....
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p?
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p?
Will defiantly work
会顽强地工作
回答by Ahmed Soliman
Add a nodemon.json
configuration file in your root folder and specify ignore patterns for example:
nodemon.json
在根文件夹中添加配置文件并指定忽略模式,例如:
nodemon.json
nodemon.json
{
"ignore": [
"*.test.js",
"dist/*"
]
}
- Note that by default
.git
,node_modules
,bower_components
,.nyc_output
,coverage
and.sass-cache
are ignored so you don't need to add them to your configuration.
- 请注意,默认情况下
.git
,node_modules
、bower_components
、.nyc_output
、coverage
和.sass-cache
会被忽略,因此您无需将它们添加到您的配置中。
Explanation: This error happens because you exceeded the max number of watchers allowed by your system (i.e. nodemon
has no more disk space to watch all the files - which probably means you are watching not important files). So you ignore non-important files that you don't care about changes in them for example the build output or the test cases.
解释:发生此错误是因为您超出了系统允许的最大观察者数量(即nodemon
没有更多的磁盘空间来观察所有文件 - 这可能意味着您正在观察不重要的文件)。因此,您可以忽略不关心其中更改的非重要文件,例如构建输出或测试用例。
回答by iClass Chima
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
This worked for me
这对我有用
回答by Vishal Verma
in my case closing the visual studio code then starting the server did the trick
在我的情况下,关闭 Visual Studio 代码然后启动服务器就成功了
Operating system - ubuntu 16.4 lts
操作系统 - ubuntu 16.4 lts
node.js version - 8.11.1
node.js 版本 - 8.11.1
npm version - 6.0.0
npm 版本 - 6.0.0
回答by vt5491
Instead of specifying a list of directories to ignore (e.g. negative), you can also specify a list of directories to watch (e.g positive):
除了指定要忽略的目录列表(例如否定),您还可以指定要监视的目录列表(例如肯定):
nodemon --watch dir1 --watch dir2 dir1/examples/index.js
In my particular case, I had one directory I wanted to watch and about nine I wanted to ignore, so specifying '--watch' was much simpler than specifying '--ignore'
在我的特殊情况下,我有一个我想查看的目录,大约有九个我想忽略,因此指定“--watch”比指定“--ignore”简单得多