Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot locate Morphdom module in NPM Workspaces #77

Open
ala-n opened this issue May 22, 2024 · 3 comments
Open

Cannot locate Morphdom module in NPM Workspaces #77

ala-n opened this issue May 22, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@ala-n
Copy link

ala-n commented May 22, 2024

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
    • 📁 another-package
      • ...
    • 📁 node_modules // Everything, including @11ty/eleventy-dev-server, @11ty/eleventy, and morphdom, loads here (by the NPM workspaces feature to share dependencies between packages)
    • 📄 package.json // Root workspaces package
    • 📄 package-lock.json

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.

@zachleat
Copy link
Member

zachleat commented Jun 4, 2024

Marginally related to 11ty/eleventy#3178

@zachleat
Copy link
Member

zachleat commented Jun 4, 2024

Can you include the command you use to run Eleventy?

@ala-n
Copy link
Author

ala-n commented Jun 4, 2024

Sure,

The actual command in root/11ty-package/pacage.json (runs in the context of root/11ty-package) is:

 eleventy --serve --incremental -- --env=development

The -- --env=development part is not directly related to the 11ty server (included just in case it indirectly affects something)

Running through workspaces root (e.g., npm run serve -w 11ty-package) does not affect path resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants