Skip to content

Discuss: Website/browser build is not intended for use with Node.js. #1245

Closed
@avih

Description

@avih

var <any-name-hljs-included> = require('./highlight.pack'); fails with ReferenceError: hljs is not defined. when executed in node.js.

This happens when downloading and extracting highlight.zip from https://highlightjs.org/download/ (tested both the default selected languages or with just one - javascript)

But it doesn't fail (and I can later use it nicely) if I build it on my own with node tools/build.js javascript or any other languages which I tried.

This happens with 9.50 but also happened with 9.40 (worked when I build it, didn't from the download).

Looking at highlight.pack.js - both the downloaded and the one which I built, it seems that the code is supposed to work also in a module environment (tests for exports availability at the beginning - identical first few LOC at both files), but it doesn't with the download.

Is it a bug? expected? IMO it should be possible to require it also with the downloaded package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions