Skip to content
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

dependency on highlight.js issue #88

Open
a-birla opened this issue Sep 28, 2017 · 9 comments
Open

dependency on highlight.js issue #88

a-birla opened this issue Sep 28, 2017 · 9 comments

Comments

@a-birla
Copy link

a-birla commented Sep 28, 2017

as this module has dependency on highlight.js, if I install highlight.js via npm and give the path of the js file created under node_modules and install angular-highlightjs via npm/bower, it does not highlight any content.
but if I use the cdn copy of highlight.js or build it locally myself, then it highlights content very well. What is the issue here?

@pc035860
Copy link
Owner

@a-birla Can you provide error messages for the node_modules setup?
Did it bundle highlight.js package correctly?

@a-birla
Copy link
Author

a-birla commented Sep 28, 2017

in the highlight.js package, I have one highlight.js file inside lib folder. If I reference that in my script, it does not apply any highlighting. There are errors when I try to use

Uncaught Error: Unknown language: "bash"
at Object.highlight (concat_vendor.js?t=1506575342991:494)
at Object.j._highlight (concat_vendor.js?t=1506575342991:57380)
at h (concat_vendor.js?t=1506575342991:57380)

Also I checked the highlight.js file on https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js is very different from what is downloaded when I do npm install highlight.js

@a-birla
Copy link
Author

a-birla commented Sep 28, 2017

screen shot 2017-09-27 at 10 12 17 pm

this is the folder structure

@pc035860
Copy link
Owner

@a-birla CDN version might already have languages registered. Looks like npm version has the languages registered in libs/index.js.

Usually you'll require highlight.js with

const hljs = require('highlight.js');
// This actually point to require('./path/to/node_modules/highlight.js/lib/index.js')
// which is defined in `package.json` key `main`

rather than require('./path/to/node_modules/highlight.js/lib/highlight.js');

@a-birla
Copy link
Author

a-birla commented Sep 28, 2017 via email

@pc035860
Copy link
Owner

So you're using gulp to concatenate js files rather than bundlers like webpack, rollup etc?
Try node_modules/highlight.js/lib/index.js then.

@a-birla
Copy link
Author

a-birla commented Sep 28, 2017

no that is not working either. If I only reference index.js, getting this error

Uncaught ReferenceError: require is not defined

@pc035860
Copy link
Owner

It seems that the npm version still requires a build procress to work if you're not using a CommonJS compatible bundler.

I'd suggest just use the CDN version or integrate the highlight.js build process into your gulp task.

@chathurabuddi
Copy link

if you are using highlight.js npm repository, try changing it to highlightjs repository. Worked for me.

https://www.npmjs.com/package/highlightjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants