-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Module not found: Error: Package path ./highlight.min.js is not exported from package @highlightjs\cdn-assets #3223
Comments
|
Yeah this is a problem, certainly. Thanks for finding and filing all these issues, but curious - is there a reason you switched from the regular NPM package to Right now I'm of the opinion that cdn-assets shouldn't have export restrictions at all (which would solve this)... but also most people bundling should probably be using the regular package (not con-assets) - so I'm truly curious why you're switching. :-) |
Because I want to use those built-in language modules directly. |
import hljs from "../node_modules/@highlightjs/cdn-assets/highlight.min.js"; I found that as long as it is imported in this way, it works normally. |
I don't understand. You can use them directly with the regular NPM package - you don't need to use cdn-assets. |
Resolved with release of 11.0.1. Exports are no longer restricted for |
Not sure this is really fixed yet - it also happens on regular npm package. I assume it's a problem here because 10.x works but 11.x does not - I don't have this issue with any other npm package. I migrated to 11.0.0 when it came out and had to roll back to latest 10.x because of this problem. I upgraded to 11.1.0 this morning and still have this issue. dependencies: "dependencies": {
...
"highlight.js": "11.1.0",
"markdown-it": "12.1.0",
"markdown-it-attrs": "4.0.0",
...
} imports: import MarkdownIt from 'markdown-it';
import MarkdownItAttrs from 'markdown-it-attrs';
import hljs from 'highlight.js/lib/core';
import 'highlight.js/styles/github.css';
hljs.registerLanguage('json', require('highlight.js/lib/languages/json'));
hljs.registerLanguage('markdown', require('highlight.js/lib/languages/markdown'));
hljs.registerLanguage('python', require('highlight.js/lib/languages/python'));
hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'));
hljs.registerLanguage('yaml', require('highlight.js/lib/languages/yaml')); attempt to lint (build same problem, but not from eslint obviously):
However, this works, but is not right: import MarkdownIt from 'markdown-it';
import MarkdownItAttrs from 'markdown-it-attrs';
import hljs from 'highlight.js/lib/core';
import '../../node_modules/highlight.js/styles/github.css';
hljs.registerLanguage('json', require('../../node_modules/highlight.js/lib/languages/json'));
hljs.registerLanguage('markdown', require('../../node_modules/highlight.js/lib/languages/markdown'));
hljs.registerLanguage('python', require('../../node_modules/highlight.js/lib/languages/python'));
hljs.registerLanguage('xml', require('../../node_modules/highlight.js/lib/languages/xml'));
hljs.registerLanguage('yaml', require('../../node_modules/highlight.js/lib/languages/yaml')); Edit |
This seems to be broken for me as well. I'm getting the following error message:
This message appears when using the dynamic import syntax await import(
/*
webpackInclude: /(java|javascript|latex|markdown|python|ruby|typescript|xml|yaml)/,
webpackChunkName: "lang-[request]"
*/
`highlight.js/lib/languages/${lang}.js`
) The following are all solutions that fix the problem for me:
"./lib/languages/*": {
"require": "./lib/languages/*.js",
"import": "./es/languages/*.js"
},
+ "./lib/languages": {
+ "require": "./lib/languages",
+ "import": "./es/languages"
+ },
await import(
/*
webpackInclude: /(java|javascript|latex|markdown|python|ruby|typescript|xml|yaml)/,
webpackChunkName: "lang-[request]"
*/
- `highlight.js/lib/languages/${lang}.js`
+ `@/../node_modules/highlight.js/lib/languages/${lang}.js`
)
Downgrading to the latest v10 release fixes this problem for me. Removing the Framework: Vue 3 (Vue CLI 5) |
There is never any reason to directly import https://nodejs.org/api/packages.html#packages_subpath_patterns Perhaps file an issue against Webpack if that is what is kicking up the error? |
I did not import the |
I realize that. That's why I suggested file a bug against your packaging software. Of course you can link to this issue and we'll see where things land. |
Using a separate variable to store the module name seems to have fixed this for me. await import(
/*
webpackInclude: /(java|javascript|latex|markdown|python|ruby|typescript|xml|yaml)/,
webpackChunkName: "lang-[request]"
*/
`highlight.js/lib/languages/${lang}.js`
) you would use: const moduleName = `highlight.js/lib/languages/${lang}.js`
await import(
/*
webpackInclude: /(java|javascript|latex|markdown|python|ruby|typescript|xml|yaml)/,
webpackChunkName: "lang-[request]"
*/
moduleName
) I have no idea why and if this actully works. Fixes my build and the example in the webpack issue though. |
I wonder though if you changed your import from build-time to run-time since now the optimizer isn't smart enough to know the string at compile time? |
That may have been the effect... but how would the compiler be smart enough to know (I don't really understand what's going on here - just guessing) |
Sorry, no idea. Thanks for sharing though. |
Describe the issue/behavior that seems buggy
Module not found: Error: Package path ./highlight.min.js is not exported from package D:\Documents\github\markdown-reader\node_modules@highlightjs\cdn-assets (see exports field in D:\Documents\github\markdown-reader\node_modules@highlightjs\cdn-assets\package.json)
Sample Code or Instructions to Reproduce
Expected behavior
Additional context
webpack 5.38.1
@highlightjs/cdn-assets 11.0.0
The text was updated successfully, but these errors were encountered: