Require npm module with browser cannot find dependency

I am new to using Node JS modules, and I use some modules in the browser that I associate with the browser to convert label text to HTML.

I have a .js file where I need a module ('markdown-it') from npm. I launch a browser to link the file to include it in the html page and it all works. My problem is when I want to add the plugin 'markdown-it-latex' . I installed it using npm, like the rest of the plugins (for example, "markdown-it-sup"), but when I require it in the file and I launch its browser, I get an error message:

Error: Cannot find module './src/ParseError' from '/home/bianca/Documents/CS/supersecret/supersecret_/node_modules/katex/dist'
at /home/bianca/.nvm/versions/node/v7.5.0/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
at load (/home/bianca/.nvm/versions/node/v7.5.0/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
at onex (/home/bianca/.nvm/versions/node/v7.5.0/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
at /home/bianca/.nvm/versions/node/v7.5.0/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:112:15)

Katex was installed via npm depending on this module, and I don’t know where to look to find the problem. The src folder is not really in katex / dist /, but in katex /, so I got confused about why it is looking for it in dist. I struggled with this for a while, and I started reading many Node tutorials to try to find the root cause, but so far I have not had success, so any help is greatly appreciated.

README for markdown-it-latex offers installation through yarn, but it is also possible to install it through npm. From what I read, this should not be a problem, but I could have missed something ...

Update: I also tried installing through yarn and using import instead of the required one (according to the docs), along with babelify to import ES6 and the same error appeared when starting the browser.

+4

Source: https://habr.com/ru/post/1691571/


All Articles