0

I started getting this error today in the test suite of an Angular.js 1.5/Angular 5 project:

HeadlessChrome 64.0.3282 (Linux 0.0.0) ERROR
  An error was thrown in afterAll
  Uncaught ReferenceError: require is not defined

The issue appears after all of my tests have run successfully. What is bizarre is it runs well locally, but it's in a Jenkins CI server where it fails. From the other developers only 1 in 10 is seeing the same problem as Jenkins.

There are tons of other posts mentioning this same error but none addressed my exact problem, like this, this, this, ...

Anybody knows what the issue can be?

Edit:

The exception happens in modernizr/lib/cli.js, but no stack-trace appears:

enter image description here

and we get no call stack either:

enter image description here

1 Answer 1

0

After looking at the bower dependencies of our project with bower ls -o, we found a difference in a transient dependency of Zurb Foundation.

In the places were it worked, modernizr was set to 3.5.0:

├─┬ foundation#5.5.1
│ ├── fastclick#1.0.6
│ ├── jquery#2.1.4
│ ├─┬ jquery-placeholder#2.0.9
│ │ └── jquery#2.1.4
│ ├─┬ jquery.cookie#1.4.1
│ │ └── jquery#2.1.4
│ └── modernizr#3.5.0

In the places were it didn't work, it was set to 3.9.0:

├─┬ foundation#5.5.1
│ ├── fastclick#1.0.6
│ ├── jquery#2.1.4
│ ├─┬ jquery-placeholder#2.0.9
│ │ └── jquery#2.1.4
│ ├─┬ jquery.cookie#1.4.1
│ │ └── jquery#2.1.4
│ └── modernizr#3.9.0

Forcing the modernizr version to 3.5.0 in bower.json solved the issue:

  "dependencies": {
    ...
    "modernizr": "3.5.0"
  }

I don't fully understand why modernizr was resolved to different versions in some computers, as in both cases we had the same Zurb Foundation's version pinned, but this was the way we fixed the issue.

7
  • It is because of the SemVer selector >=2... so it will use the latest release. This is normal and expected. You should file an issue for the modernizr project. See github.com/foundation/foundation-sites/blob/v5.5.1/…
    – user753676
    Feb 17, 2020 at 6:20
  • To be exact, require is only available in Node environments. So far I can not see the cause in the modernizr releases. Can you share the full stacktrace with us?
    – user753676
    Feb 17, 2020 at 6:46
  • @DanielRuf There is no stack trace printed out, the 3 lines I posted are all the error information we get. We found out it was modernizr because of that 1 developer for whom the issue reproduced locally, so he could debug the test execution. I'll ask him for an screenshot of the call stack when he gets the error and I'll update tomorrow.
    – DWilches
    Feb 18, 2020 at 4:36
  • Can you share a repo with the code that triggers / causes this?
    – user753676
    Feb 18, 2020 at 5:25
  • That would be great. Because I think it was caused by something else.
    – user753676
    Feb 18, 2020 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.