eleventy-dev-server
eleventy-dev-server copied to clipboard
Cannot locate Morphdom module in NPM Workspaces
Steps to Reproduce
The following project structure (with NPM workspaces):
- 📁 root
- 📁 11ty-package
- 📁 view
- 📄 index.html // Some stuff to render, serve, and watch
- 📄 .eleventy.js // 11ty config, so 11ty runs here
- 📄 package.json // The one referencing @11ty/eleventy and @11ty/eleventy-dev-server
- 📁 view
- 📁 another-package
- ...
- 📁 node_modules // Everything, including
@11ty/eleventy-dev-server
,@11ty/eleventy
, andmorphdom
, loads here (by the NPM workspaces feature to share dependencies between packages) - 📄 package.json // Root workspaces package
- 📄 package-lock.json
- 📁 11ty-package
The server runs in the context of the root/11ty-package
subpackage.
The domDiff
is enabled (default).
Any HTML-related changes lead to an exception during the watch process, with the following error:
[11ty] Unhandled rejection in promise: (more in DEBUG output)
[11ty] The "path" argument must be of type string or an instance of Buffer or URL. Received undefined (via TypeError)
[11ty]
[11ty] Original error stack trace: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
[11ty] at Object.readFileSync (node:fs:451:42)
[11ty] at EleventyDevServer._getFileContents (L:\DMT\smart-wc-library\node_modules\@11ty\eleventy\node_modules\@11ty\eleventy-dev-server\server.js:322:23)
[11ty] at EleventyDevServer.eleventyDevServerMiddleware (L:\DMT\smart-wc-library\node_modules\@11ty\eleventy\node_modules\@11ty\eleventy-dev-server\server.js:426:29)
[11ty] at EleventyDevServer.onRequestHandler (L:\DMT\smart-wc-library\node_modules\@11ty\eleventy\node_modules\@11ty\eleventy-dev-server\server.js:548:11)
[11ty] at Server.emit (node:events:518:28)
[11ty] at parserOnIncoming (node:_http_server:1143:12)
[11ty] at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)
Root Cause Details:
The EleventyDevServer._getFileContents
method tries to read the file content of the morphdom
module (ref), but it cannot resolve the path to the file.
It uses the following path as a base ./node_modules/morphdom/dist/morphdom-esm.js
to create the following searchLocations
:
[
'root/11ty-package/node_modules/morphdom/dist/morphdom-esm.js',
'root/node_modules/@11ty/eleventy/node_modules/@11ty/eleventy-dev-server/node_modules/morphdom/dist/morphdom-esm.js',
'root/node_modules/@11ty/eleventy/node_modules/morphdom/dist/morphdom-esm.js'
]
None of them contain morphdom
, which is under root/node_modules/morphdom/**
in the current state of things.