webpack: Any file js, that has an "assert" string in it, throws an error.

Bug report

What is the current behavior?

After i removed the package-lock.json and reinstalled i got this error.

If the current behavior is a bug, please provide the steps to reproduce.

It is a big project, i can’t reproduce, but could you please look at the error, because it only happens in files that have assert functions or imports.

What is the expected behavior? I think it is a patch in some of the packages, so no idea where it happend. What happens now is that any file that has assert in the file it will throw an error.

What is weird is that in the error it happens that has assert files:

[2] ERROR in ./node_modules/@uirouter/core/lib-esm/transition/hookBuilder.js 1:17
[2] Module parse failed: Unexpected token (1:17)
[2] You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
[2] > import { extend, assertPredicate, unnestR, identity } from '../common/common';
[2] | import { isArray } from '../common/predicates';
[2] | import { TransitionHookPhase, TransitionHookScope, } from './interface';
[2]  @ ./node_modules/@uirouter/core/lib-esm/transition/index.js 14:0-30 14:0-30
[2]  @ ./node_modules/@uirouter/core/lib-esm/index.js 6:0-35 6:0-35
[2]  @ ./node_modules/@uirouter/angularjs/lib-esm/index.js 16:0-39 17:0-16 18:0-31 18:0-31
[2]  @ ./src/client/vendor.js 34:0-30
[2] 
[2] ERROR in ./node_modules/@uirouter/core/lib-esm/vanilla/injector.js 1:17
[2] Module parse failed: Unexpected token (1:17)
[2] You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
[2] > import { extend, assertPredicate, isFunction, isArray, isInjectable, } from '../common/index';
[2] | // globally available injectables
[2] | var globals = {};
[2]  @ ./node_modules/@uirouter/core/lib-esm/vanilla/index.js 8:0-27 8:0-27
[2]  @ ./node_modules/@uirouter/core/lib-esm/vanilla.js 1:0-32 1:0-32
[2]  @ ./node_modules/@uirouter/core/lib-esm/index.js 11:0-26 11:0-26
[2]  @ ./node_modules/@uirouter/angularjs/lib-esm/index.js 16:0-39 17:0-16 18:0-31 18:0-31
[2]  @ ./src/client/vendor.js 34:0-30
[2] 
[2] ERROR in ./node_modules/angular-animate/angular-animate.js 64:9
[2] Module parse failed: Unexpected token (64:9)
[2] You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
[2] | 
[2] | var ngMinErr = angular.$$minErr('ng');
[2] > function assertArg(arg, name, reason) {
[2] |   if (!arg) {
[2] |     throw ngMinErr('areq', 'Argument \'{0}\' is {1}', (name || '?'), (reason || 'required'));
[2]  @ ./node_modules/angular-animate/index.js 1:0-28
[2]  @ ./node_modules/angular-material/index.js 5:0-26
[2]  @ ./src/client/vendor.js 36:0-27
[2] 
[2] ERROR in ./node_modules/angular/angular.js 2115:9
[2] Module parse failed: Unexpected token (2115:9)
[2] You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
[2] |  * throw error if the argument is falsy.
[2] |  */
[2] > function assertArg(arg, name, reason) {
[2] |   if (!arg) {
[2] |     throw ngMinErr('areq', 'Argument \'{0}\' is {1}', (name || '?'), (reason || 'required'));
[2]  @ ./node_modules/angular/index.js 1:0-20
[2]  @ ./src/client/vendor.js 24:17-35
[2] 
[2] ERROR in ./node_modules/buffer/index.js 184:9
[2] Module parse failed: Unexpected token (184:9)
[2] You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
[2] | Object.setPrototypeOf(Buffer, Uint8Array)
[2] | 
[2] > function assertSize (size) {
[2] |   if (typeof size !== 'number') {
[2] |     throw new TypeError('"size" argument must be of type number')
[2]  @ ./node_modules/qrcode/lib/core/reed-solomon-encoder.js 3:13-37
[2]  @ ./node_modules/qrcode/lib/core/qrcode.js 10:25-58
[2]  @ ./node_modules/qrcode/lib/browser.js 4:13-37
[2]  @ ./src/client/angular/core/factory/ngivr-core-pdf-generator.js 57:43-60
[2]  @ ./src/client/injector.js 80:0-61
[2]  @ ./src/client/angular.js 17:0-24
[2]  @ ./src/client/main.js 148:0-20
[2]  @ ./src/client/main-development.js 6:19-47 29:0-17
[2] 
[2] ERROR in ./node_modules/jquery/dist/jquery.js 936:9
[2] Module parse failed: Unexpected token (936:9)
[2] You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
[2] |  * @param {Function} fn Passed the created element and returns a boolean result
[2] |  */
[2] > function assert( fn ) {
[2] |   var el = document.createElement( "fieldset" );
[2] | 
[2]  @ ./src/client/vendor.js 10:27-44
[2] 
[2] webpack 5.45.0 compiled with 6 errors in 287 ms
[2] ℹ 「wdm」: Failed to compile.

Other relevant information: webpack version: 5 latest Node.js version: 14 latest Operating System: Linux Mint latest Additional tools:

See this is the main errors, which is very weird:

The actual errors all assert:

function assert( fn ) {
function assertSize (size) {
function assertArg(arg, name, reason) {
function assertArg(arg, name, reason) {
import { extend, assertPredicate, isFunction, isArray, isInjectable, } from '../common/index';
import { extend, assertPredicate, unnestR, identity } from '../common/common';

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Let’s keep open until we do patch release

I’m curious how the previous PR passed to merge that in, when the current one to fix this issue is not passing?