highlight.js icon indicating copy to clipboard operation
highlight.js copied to clipboard

Module not found: Error: Package path ./lib/index is not exported from package /node_modules/highlight.js

Open JamesTang616 opened this issue 2 years ago • 3 comments

I'm using Laravel, When I run npm run dev, it shows this:

ERROR in ./resources/assets/vendor/libs/highlight/highlight.js 4:0-42
Module not found: Error: Package path ./lib/index is not exported from package /home/wwwroot/myproject/node_modules/highlight.js (see exports field in /home/wwwroot/myproject/node_modules/highlight.js/package.json)

I checked /home/wwwroot/myproject/node_modules/highlight.js and there is ./lib/index.js I've changed these in myproject before running npm run dev with root, but nothing changed:

chmod 775 myproject -R

chown www:www -R myproject

JamesTang616 avatar Jan 02 '23 09:01 JamesTang616

We don't export lib/index... if you want the full library (lib/index) you should just import "highlight.js" by name, rather than trying to reference an index file.

joshgoebel avatar Jan 02 '23 12:01 joshgoebel

Thank you for your response, but why can't my project find ./lib/index? Is there any reason I can check. I'm newer to this npm thing.

JamesTang616 avatar Jan 02 '23 13:01 JamesTang616

Are you trying to use the library server-side with Node or build it for client-side usage?

joshgoebel avatar Jan 02 '23 17:01 joshgoebel