diff --git a/doc/api/esm.md b/doc/api/esm.md index 60c0a6f286c0ec..88b4f01f60deee 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -801,6 +801,22 @@ property: ## Differences Between ES Modules and CommonJS +### Absolute file paths don't work on Windows + +`import` accepts _absolute specifiers_. These are similar to _absolute paths_ +on linux and MacOS, and therefore they are also accepted. +But on Windows, importing an _absolute path_ to a file will not work. +To ensure cross platform compatibility, file paths should be converted into +URLs. + +```js +import { pathToFileURL } from 'url'; + +const fileUrl = pathToFileURL('c:\\path\\to\\file.js').href; + +await import(fileUrl); +``` + ### Mandatory file extensions A file extension must be provided when using the `import` keyword. Directory