-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Versions
- @hashicorp/[email protected]
- Node: v14.18.2
Summary
I just tried upgrading from the older @hashicorp/remark-plugins to @hashicorp/platform-remark-plugins. I immediately get an error when trying to import anchorLinks:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/mark/xxx/node_modules/@hashicorp/platform-remark-plugins/util/generate-slug' imported from /home/mark/xxx/node_modules/@hashicorp/platform-remark-plugins/plugins/anchor-links/index.js
at new NodeError (internal/errors.js:322:7)
at finalizeResolution (internal/modules/esm/resolve.js:308:11)
at moduleResolve (internal/modules/esm/resolve.js:731:10)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:842:11)
at Loader.resolve (internal/modules/esm/loader.js:89:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
at link (internal/modules/esm/module_job.js:75:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Analysis
I believe the problem here is that the package has been migrated to ESM incompletely. Specifically, imports in an ESM project must include the file extension. This seems to have been done for most files, but packages/remark-plugins/plugins/anchor-links/index.js still has an import without a file extension. I believe line 1 of that file needs to change:
- import { generateSlug, generateAriaLabel } from '../../util/generate-slug'
+ import { generateSlug, generateAriaLabel } from '../../util/generate-slug.js'Metadata
Metadata
Assignees
Labels
No labels