Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

NodeJs: Regions is not defined (in strict_mode) #18

Open
MartinLoeper opened this issue Dec 5, 2017 · 5 comments · May be fixed by #20
Open

NodeJs: Regions is not defined (in strict_mode) #18

MartinLoeper opened this issue Dec 5, 2017 · 5 comments · May be fixed by #20

Comments

@MartinLoeper
Copy link

MartinLoeper commented Dec 5, 2017

Hi, I'm getting the following error:

ReferenceError: regions is not defined
    at d (/var/app/current/node_modules/moment-holiday/build/moment-holiday-us.min.js:6:3117)
    at Object.add (/var/app/current/node_modules/moment-holiday/build/moment-holiday-us.min.js:6:5870)
    at Object.<anonymous> (/var/app/current/node_modules/moment-holiday/build/moment-holiday-us.min.js:16:116)
    at Object.<anonymous> (/var/app/current/node_modules/moment-holiday/build/moment-holiday-us.min.js:16:138)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
    at Module.require (module.js:517:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/app/current/bin/src/app/utils/cost/strategies/publicHoliday.strategy.js:5:1)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)

Any idea why this is happening?
I'm using NodeJs v8.4.0 on AWS with typescript compiler.

The library is included as follows:

import * as moment from "moment";
import "moment-holiday";
@MartinLoeper
Copy link
Author

I found out, that strict_mode causes this error.
This script seems not to work on NodeJs in strict_mode.

@MartinLoeper MartinLoeper changed the title NodeJs: Regions is not defined NodeJs: Regions is not defined (in strict_mode) Dec 5, 2017
@MartinLoeper
Copy link
Author

There are several variable declarations missing.
If someone is interested in how to get this library working in strict mode, please check out my fork: https://github.com/MartinLoeper/moment-holiday

@bjhewitt
Copy link

bjhewitt commented Feb 9, 2018

@MartinLoeper are you planning to do a pull request to get your changes into this upstream repo (and thus, hopefully, into the NPM module)? I'd love to get these strict/minification issues resolved in the module to get my build working with less fuss.

For me, I had to move that variable declaration out to the top module scope to avoid minification errors. (bjhewitt@388ec0a#diff-5ecd2a99d029816f5c37fce3481f99bd)

@MartinLoeper MartinLoeper linked a pull request Feb 12, 2018 that will close this issue
@MartinLoeper
Copy link
Author

I provided the PR =)
However, I did not notice any minification errors. Everything worked well for the following command:
node_modules/.bin/gulp --name=moment-holiday-de.js --locale=Germany --locale=Easter --set=Germany --set=Easter

@bjhewitt
Copy link

Thanks. I'm bundling and minifying numerous components together, so although moment-holiday is generating the error, it's possible there's something else at play. In any case, moving the variable declaration worked.

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

Successfully merging a pull request may close this issue.

2 participants