diff --git a/doc/api/errors.md b/doc/api/errors.md
index d16149b00bec50..18396f0ef8dfad 100644
--- a/doc/api/errors.md
+++ b/doc/api/errors.md
@@ -2412,6 +2412,12 @@ The `--entry-type=...` flag is not compatible with the Node.js REPL.
Used when an [ES Module][] loader hook specifies `format: 'dynamic'` but does
not provide a `dynamicInstantiate` hook.
+
+#### `ERR_FEATURE_UNAVAILABLE_ON_PLATFORM`
+
+Used when a feature that is not available
+to the current platform which is running Node.js is used.
+
#### `ERR_STREAM_HAS_STRINGDECODER`
diff --git a/doc/api/fs.md b/doc/api/fs.md
index 01d99c80366f45..9ed072ad1e4871 100644
--- a/doc/api/fs.md
+++ b/doc/api/fs.md
@@ -3766,6 +3766,8 @@ The `fs.watch` API is not 100% consistent across platforms, and is
unavailable in some situations.
The recursive option is only supported on macOS and Windows.
+An `ERR_FEATURE_UNAVAILABLE_ON_PLATFORM` exception will be thrown
+when the option is used on a platform that does not support it.
#### Availability
diff --git a/lib/fs.js b/lib/fs.js
index 40453bc15c1efb..5e132fe43cfb72 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -62,7 +62,8 @@ const {
ERR_FS_FILE_TOO_LARGE,
ERR_INVALID_ARG_VALUE,
ERR_INVALID_ARG_TYPE,
- ERR_INVALID_CALLBACK
+ ERR_INVALID_CALLBACK,
+ ERR_FEATURE_UNAVAILABLE_ON_PLATFORM
},
uvException
} = require('internal/errors');
@@ -129,6 +130,7 @@ let FileReadStream;
let FileWriteStream;
const isWindows = process.platform === 'win32';
+const isOSX = process.platform === 'darwin';
function showTruncateDeprecation() {
@@ -1359,7 +1361,8 @@ function watch(filename, options, listener) {
if (options.persistent === undefined) options.persistent = true;
if (options.recursive === undefined) options.recursive = false;
-
+ if (options.recursive && !(isOSX || isWindows))
+ throw new ERR_FEATURE_UNAVAILABLE_ON_PLATFORM('watch recursively');
if (!watchers)
watchers = require('internal/fs/watchers');
const watcher = new watchers.FSWatcher();
diff --git a/lib/internal/errors.js b/lib/internal/errors.js
index 5b80092ee312de..d90ea08d4dce13 100644
--- a/lib/internal/errors.js
+++ b/lib/internal/errors.js
@@ -803,6 +803,10 @@ E('ERR_FALSY_VALUE_REJECTION', function(reason) {
this.reason = reason;
return 'Promise was rejected with falsy value';
}, Error);
+E('ERR_FEATURE_UNAVAILABLE_ON_PLATFORM',
+ 'The feature %s is unavailable on the current platform' +
+ ', which is being used to run Node.js',
+ TypeError);
E('ERR_FS_FILE_TOO_LARGE', 'File size (%s) is greater than 2 GB', RangeError);
E('ERR_FS_INVALID_SYMLINK_TYPE',
'Symlink type must be one of "dir", "file", or "junction". Received "%s"',
diff --git a/test/parallel/test-fs-watch-recursive.js b/test/parallel/test-fs-watch-recursive.js
index 4985ece0e0ec15..70b413814e78f4 100644
--- a/test/parallel/test-fs-watch-recursive.js
+++ b/test/parallel/test-fs-watch-recursive.js
@@ -2,8 +2,6 @@
const common = require('../common');
-if (!(common.isOSX || common.isWindows))
- common.skip('recursive option is darwin/windows specific');
const assert = require('assert');
const path = require('path');
@@ -20,6 +18,11 @@ const testsubdir = fs.mkdtempSync(testDir + path.sep);
const relativePathOne = path.join(path.basename(testsubdir), filenameOne);
const filepathOne = path.join(testsubdir, filenameOne);
+if (!common.isOSX && !common.isWindows) {
+ assert.throws(() => { fs.watch(testDir, { recursive: true }); },
+ { code: 'ERR_FEATURE_UNAVAILABLE_ON_PLATFORM' });
+ return;
+}
const watcher = fs.watch(testDir, { recursive: true });
let watcherClosed = false;