Skip to content

ReferenceError: moment is not defined #643

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

Open
Pascal76 opened this issue Mar 19, 2025 · 1 comment
Open

ReferenceError: moment is not defined #643

Pascal76 opened this issue Mar 19, 2025 · 1 comment

Comments

@Pascal76
Copy link

Pascal76 commented Mar 19, 2025

Hello,

I try to use node-export-server from docker with a formatter using moment.js :

datethe = moment().year(datetheYW[0]).isoWeek(datetheYW[1]).startOf('isoWeek').format('YYYY-MM-DD') + '  w' + datetheYW[1] + '';

but I got this error : ReferenceError: moment is not defined

/bin/docker run -u 0:0 --rm --tmpfs=/run highcharts_es cat lib/schemas/config.js
contains :
custom: [
'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.45/moment-timezone-with-data.min.js'
]

On the dockerfile :
ENV HIGHCHARTS_MOMENT="YES" (or true or 1)
I am not sure it is still valid because HIGHCHARTS_MOMENT does not appear on the documentation
+
npm install -S moment moment-timezone luxon (...)
I am not sure it is needed given lib/schemas/config.js

Could you help me to understand how to make it work please ?

The command line:
/usr/local/bin/highcharts-export-server --resources '[]' --allowFileResources true --allowCodeExecution true --infile "$from" --outfile "$to" $width $height $scale --logLevel 2 --nologo true 2>&1

@Pascal76
Copy link
Author

The solution I found, but I don't think it is the best (I would prefer it gets the local file)

On the Dockerfile I added :
ADD ["template.html","templates"]

And on template.html I added :
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.45/moment-timezone-with-data.min.js"></script>

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

1 participant