Closed khusamov closed 5 years ago
Could you please test, if it works with:
.use(require('markdown-it-anchor').default)
This error seems to be reported before (#54) and is related to (#12). If the above suggestion works, we should search for a fix like
.use(require('markdown-it-anchor').default)
I do not understand where to insert this code.
I’m affected by this error as well after upgrading to the latest version. I can confirm that the workaround suggested by @nagaozen seems to fix it.
The workaround does not work for me. Either for markdown-it-anchor
or for markdown-it-toc-done-right
.
.use(require('markdown-it-anchor').default)
I do not understand where to insert this code.
When using markdown-it-anchor
, usually you are importing the packages either with import ...
or require(...)
. We've encountered a bug before when babel was transpiling the code into something else and started using exports.default
instead of the Node.js exports
, so loading the package as require('markdown-it-anchor').default
should fix the problem.
Just another note: In the past, this package required babel transpilation due to modern ES6+ features used in the source code, but with the latest versions it's not required anymore, just require as a ES5 dependency as shown here https://npm.runkit.com/markdown-it-toc-done-right.
I'm hitting the same problem after v5.1.0.
The workaround does work for v5.2.4.
But if it's not going to be fixed, I think you should deprecate the v5.x.x versions after v5.1.0 and update the semantic version to v6.x.x. At a minimum, I'd note the need at the top of the npmjs documentation for the time being...
Additionally, there are no version tags here after v5.1.0 despite several later released versions on
Fixed by including packages using the import
statement:
import markdownItAnchor from 'markdown-it-anchor'
import markdownItTocDoneRight from 'markdown-it-toc-done-right'
const md = require('markdown-it')
.use(markdownItAnchor, {
permalink: true,
permalinkBefore: true,
permalinkSymbol: '' // §
})
.use(markdownItTocDoneRight)
still doesn't work with nuxt @nuxtjs/markdownit
module.
Since we migrated our project to microbundle, there are 3 flavours of production ready files built in the dist folder:
dist/markdownItAnchor.js
, specified as main
in package.json
. This is the default, CJS compatible format. It can be used as var md = require('markdown-it-anchor')
. It can be tested at https://npm.runkit.com/markdown-it-anchordist/markdownItAnchor.mjs
, specified as module
in package.json
. This version is made for modern ES6 environments. Its made to make many modern optimized builds possible, like using tree-shaking. You have to use/configure your bundler for this to work. In case you don't have a deep knowledge about your stack, its easy to find out by experimentation: if you are using import markdownItAnchor from markdown-it-anchor
you are using ES6 syntax, that command is equivalent to const markdownItAnchor = require('markdown-it-anchor').default
.dist/markdownItAnchor.umd.js
, specified as unpkg
in package.json
. This version is made for the browser. It exposes the library as window.markdownItAnchor
.There are no breaking changes, in the version 5.x.x since the exactly same version of runkit.js
is still working fine. Errors shown are usually downstream or problems with configuration.
Fixed by including packages using the
import
statement:import markdownItAnchor from 'markdown-it-anchor' import markdownItTocDoneRight from 'markdown-it-toc-done-right' const md = require('markdown-it') .use(markdownItAnchor, { permalink: true, permalinkBefore: true, permalinkSymbol: '' // § }) .use(markdownItTocDoneRight)
This fix issue.
Running into "TypeError: plugin.apply is not a function" with version 5.2.4.