Ember-cli-babel throwing error when linking addon

I’m having an ember-cli-babel issue when linking one of my addons to our apps.

It’s throwing the following error:

Class constructor Plugin cannot be invoked without 'new'


Stack Trace and Error Report: /tmp/error.dump.ba805c6249cefdf147b719dbcc70ebac.log
ERROR Summary:

  - broccoliBuilderErrorStack: [undefined]
  - code: [undefined]
  - codeFrame: [undefined]
  - errorMessage: Class constructor Plugin cannot be invoked without 'new'
  - errorType: [undefined]
  - location:
    - column: [undefined]
    - file: [undefined]
    - line: [undefined]
  - message: Class constructor Plugin cannot be invoked without 'new'
  - name: TypeError
  - nodeAnnotation: [undefined]
  - nodeName: [undefined]
  - originalErrorMessage: [undefined]
  - stack: TypeError: Class constructor Plugin cannot be invoked without 'new'
    at new Funnel (/home/karel/gf/ember-mist-components/node_modules/ember-cli-babel/node_modules/broccoli-funnel/index.js:57:10)
    at Class.transpileTree (/home/karel/gf/ember-mist-components/node_modules/ember-cli-babel/index.js:166:40)
    at Object.toTree (/home/karel/gf/ember-mist-components/node_modules/ember-cli-babel/index.js:180:30)
    at /home/karel/gf/atlas/node_modules/ember-cli-preprocess-registry/preprocessors.js:188:26
    at Array.forEach (<anonymous>)
    at processPlugins (/home/karel/gf/atlas/node_modules/ember-cli-preprocess-registry/preprocessors.js:186:11)
    at Function.module.exports.preprocessJs (/home/karel/gf/atlas/node_modules/ember-cli-preprocess-registry/preprocessors.js:179:10)
    at Class.preprocessJs (/home/karel/gf/atlas/node_modules/ember-cli/lib/models/addon.js:1297:25)
    at Class.treeForAddonTestSupport (/home/karel/gf/atlas/node_modules/ember-cli/lib/models/addon.js:945:19)
    at Class._treeFor (/home/karel/gf/atlas/node_modules/ember-cli/lib/models/addon.js:668:33)

Removing the addon’s node_modules and installing the packges again let’s me run my app once. But the second time it’s back to this error.

give us more information , the addon that is causing the problem and the version of ember you are using , are you using embroider ?

What information do you need? It’s our own addon, it is causing issues in all (test) apps it is being linked to, except for it’s own dummy app.

Not using embroider.

devDependencies: {
    'ember-cli-sri': '^2.1.1',
    'loader.js': '^4.7.0',
    'babel-eslint': '^10.1.0',
    '@types/object-hash': '^1.3.1',
    'ember-cli-typescript-blueprints': '^3.0.0',
    'ember-disable-prototype-extensions': '~1.1.3',
    '@types/stripe-v3': '^3.1.9',
    '@types/ws': '^7.2.4',
    'ember-cli-sass': '~10.0.0',
    sass: '~1.17.2',
    '@ember/optional-features': '^2.0.0',
    'ember-cli-inject-live-reload': '^2.0.2',
    'ember-export-application-global': '^2.0.1',
    'ember-load-initializers': '^2.1.2',
    'els-addon-typed-templates': '^4.2.4',
    'ember-template-lint-typed-templates': '^0.1.7',
    'ember-cli-terser': '^4.0.2',
    '@types/rsvp': '^4.0.4',
    'qunit-dom': '^2.0.0',
    'ember-cli-code-coverage': '^1.0.3',
    prettier: '^2.6.2',
    webpack: '^5.72.1',
    'ember-cli-dependency-checker': '^3.3.1',
    'ember-source': '~4.4.0',
    'eslint-plugin-prettier': '^4.2.1',
    'broccoli-asset-rev': 'github:ember-cli/broccoli-asset-rev#pull/147/head',
    'ember-cli-string-helpers': '^6.0.0',
    'ember-math-helpers': '^2.18.1',
    'ember-raf-scheduler': '^0.3.0',
    concurrently: '^7.6.0',
    '@types/ember__test': '^4.0.1',
    'eslint-plugin-qunit': '^7.3.4',
    '@embroider/test-setup': '^1.6.0',
    'ember-cli': '~4.4.1',
    'ember-qunit': '^6.1.1',
    'ember-template-lint': '^4.8.0',
    qunit: '^2.19.3',
    '@types/ember-data': '^3.16.15',
    '@types/ember-data__adapter': '^3.16.2',
    '@types/ember-data__model': '^3.16.3',
    '@types/ember-data__serializer': '^3.16.2',
    '@types/ember-data__store': '^3.16.2',
    '@ember/test-helpers': '^2.7.0',
    'eslint-config-prettier': '^8.6.0',
    'eslint-plugin-n': '^15.6.1',
    eslint: '^8.33.0',
    typescript: '^4.9.5',
    '@typescript-eslint/eslint-plugin': '^5.51.0',
    '@typescript-eslint/parser': '^5.51.0',
    'eslint-plugin-ember': '^11.4.6',
    '@tsconfig/ember': '^2.0.0',
    '@types/ember': '^4.0.3',
    '@types/ember__application': '^4.0.5',
    '@types/ember__array': '^4.0.3',
    '@types/ember__component': '^4.0.12',
    '@types/ember__controller': '^4.0.4',
    '@types/ember__debug': '^4.0.3',
    '@types/ember__destroyable': '^4.0.1',
    '@types/ember__engine': '^4.0.4',
    '@types/ember__error': '^4.0.2',
    '@types/ember__object': '^4.0.5',
    '@types/ember__polyfills': '^4.0.1',
    '@types/ember__routing': '^4.0.12',
    '@types/ember__runloop': '^4.0.2',
    '@types/ember__service': '^4.0.2',
    '@types/ember__string': '^3.0.10',
    '@types/ember__template': '^4.0.1',
    '@types/ember__utils': '^4.0.2',
    '@types/ember__ordered-set': '^4.0.2',
    '@types/qunit': '^2.19.4',
    'ember-resolver': '^10.0.0'
  },
  dependencies: {
    'moment-duration-format': '^2.3.2',
    'object-hash': '^2.0.3',
    '@popperjs/core': '^2.3.3',
    transliteration: '^2.1.11',
    moment: '^2.29.1',
    'ember-set-helper': '^2.0.0',
    'ember-data': '~3.28.0',
    'moment-timezone': '^0.5.34',
    'ember-query-params-service': '^0.7.0',
    'ember-click-outside': '^3.0.0',
    'ember-composable-helpers': '^5.0.0',
    'ember-cli-babel': '^7.26.11',
    'ember-cli-htmlbars': '^6.0.1',
    'tracked-maps-and-sets': '^3.0.2',
    'ember-auto-import': '^2.4.1',
    '@glimmer/component': '^1.1.2',
    '@glimmer/tracking': '^1.1.2',
    'mock-socket': '^9.1.2',
    'ember-test-selectors': '^6.0.0',
    '@html-next/vertical-collection': '^4.0.0',
    'ember-concurrency': '^2.3.7',
    'ember-cached-decorator-polyfill': '^1.0.1',
    'ember-intl': '6.0.0-beta.4',
    'ember-promise-worker': '^2.0.0',
    '@embroider/macros': '^1.10.0',
    '@getflights/ember-attribute-validations': '^3.0.1',
    '@adopted-ember-addons/ember-stripe-elements': '^2.0.4',
    'ember-cli-typescript': '^5.2.1',
    '@getflights/ember-field-components': '^4.1.0',
    flatpickr: 'https://github.com/getflights/flatpickr/releases/download/4.6.14/flatpickr-4.6.14.tar.gz',
    'ember-power-select': '^6.0.1',
    '@getflights/ember-mist-components': '^8.2.2'
  }

I am also having an issue running addons linked through npm link.

The published version works fine, but the linked source (same version) will break the app build.

Mine gets stuck on “Babel Fallback - Addon#processedAddonJsFiles” in the build status. No obvious errors like you though.

somewhere you are calling Plugin without instantiating it , it should be like : let plugin = new Plugin();

I am not calling new Plugin anywhere in my build code. The error is cauised by ember-cli-babel /broccoli-funnel as you can see from the error earlier:

...
- stack: TypeError: Class constructor Plugin cannot be invoked without 'new'
    at new Funnel (/home/karel/gf/ember-mist-components/node_modules/ember-cli-babel/node_modules/broccoli-funnel/index.js:57:10)
    at Class.transpileTree (/home/karel/gf/ember-mist-components/node_modules/ember-cli-babel/index.js:166:40)
    ...

This looks like version skew. Some dependency is getting a version of broccoli-funnel that it doesn’t expect. Older versions didn’t require new and newer versions do.

This is common when using package linking, because

  • node is incredibly sloppy when it comes to dependency resolution, allowing many things to work by accident in ways that break surprisingly as soon as somebody does something less common (like using package linking)
  • and the typical clients like yarn and npm don’t even bother trying to give linked packages correct peerDependencies.

You can run npx are-my-node-modules-messed-up to get a summary of which packages are seeing different dependencies than they asked for.

It’s usually possible for manually patch over this kind of problem by linking even more packages. Alternatively, some people like yalc instead of yarn link or npm link.

2 Likes
cockpit asked for flatpickr https://github.com/getflights/flatpickr/releases/download/4.6.14/flatpickr-4.6.14.tar.gz but got 4.6.14
  - in dependencies at .
quick-temp asked for rimraf ^2.5.4 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/quick-temp
broccoli-funnel asked for broccoli-plugin ^1.3.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-babel-transpiler/node_modules/broccoli-funnel
broccoli-funnel asked for rimraf ^2.4.3 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-babel-transpiler/node_modules/broccoli-funnel
broccoli-merge-trees asked for broccoli-plugin ^1.3.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-babel-transpiler/node_modules/broccoli-merge-trees
fs-updater asked for rimraf ^2.6.2 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/fs-updater
broccoli-persistent-filter asked for async-disk-cache ^1.2.1 but got 2.1.0
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-babel-transpiler/node_modules/broccoli-persistent-filter
broccoli-persistent-filter asked for broccoli-plugin ^1.0.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-babel-transpiler/node_modules/broccoli-persistent-filter
broccoli-persistent-filter asked for rimraf ^2.6.1 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-babel-transpiler/node_modules/broccoli-persistent-filter
broccoli-persistent-filter asked for sync-disk-cache ^1.3.3 but got 2.1.0
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-babel-transpiler/node_modules/broccoli-persistent-filter
broccoli-debug asked for broccoli-plugin ^1.2.1 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-debug
broccoli-funnel asked for broccoli-plugin ^1.3.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/ember-cli-babel/node_modules/broccoli-funnel
broccoli-plugin asked for rimraf ^2.3.4 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-stew/node_modules/broccoli-funnel/node_modules/broccoli-plugin
broccoli-funnel asked for rimraf ^2.4.3 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-stew/node_modules/broccoli-funnel
broccoli-plugin asked for rimraf ^2.3.4 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-stew/node_modules/broccoli-merge-trees/node_modules/broccoli-plugin
broccoli-persistent-filter asked for async-disk-cache ^1.2.1 but got 2.1.0
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-stew/node_modules/broccoli-persistent-filter
broccoli-plugin asked for rimraf ^2.3.4 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-stew/node_modules/broccoli-persistent-filter/node_modules/broccoli-plugin
broccoli-persistent-filter asked for rimraf ^2.6.1 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-stew/node_modules/broccoli-persistent-filter
broccoli-persistent-filter asked for sync-disk-cache ^1.3.3 but got 2.1.0
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-stew/node_modules/broccoli-persistent-filter
broccoli-plugin asked for rimraf ^2.3.4 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-stew/node_modules/broccoli-plugin
broccoli-file-creator asked for broccoli-plugin ^1.1.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-file-creator
broccoli-caching-writer asked for broccoli-plugin ^1.2.1 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-caching-writer
broccoli-caching-writer asked for rimraf ^2.2.8 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-caching-writer
broccoli-merge-files asked for broccoli-plugin ^1.3.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-merge-files
broccoli-merge-trees asked for broccoli-plugin ^1.3.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/@glimmer/component/node_modules/broccoli-merge-trees
broccoli-merge-trees asked for broccoli-plugin ^1.3.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/ember-data-model-fragments/node_modules/broccoli-merge-trees
broccoli-rollup asked for broccoli-plugin ^1.2.1 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-rollup
broccoli-templater asked for broccoli-plugin ^1.3.1 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-templater
broccoli-templater asked for rimraf ^2.6.2 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/broccoli-templater
broccoli-persistent-filter asked for async-disk-cache ^1.2.1 but got 2.1.0
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/ember-text-measurer/node_modules/broccoli-persistent-filter
broccoli-plugin asked for rimraf ^2.3.4 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/ember-text-measurer/node_modules/broccoli-persistent-filter/node_modules/broccoli-plugin
broccoli-persistent-filter asked for rimraf ^2.6.1 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/ember-text-measurer/node_modules/broccoli-persistent-filter
broccoli-persistent-filter asked for sync-disk-cache ^1.3.3 but got 2.1.0
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/ember-text-measurer/node_modules/broccoli-persistent-filter
broccoli-plugin asked for rimraf ^2.3.4 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/ember-text-measurer/node_modules/broccoli-plugin
broccoli-funnel asked for broccoli-plugin ^1.3.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/ember-simple-auth/node_modules/broccoli-funnel
broccoli-funnel asked for rimraf ^2.4.3 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/ember-simple-auth/node_modules/broccoli-funnel
broccoli-funnel asked for broccoli-plugin ^1.3.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/fastboot-transform/node_modules/broccoli-funnel
broccoli-funnel asked for rimraf ^2.4.3 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/fastboot-transform/node_modules/broccoli-funnel
broccoli-merge-trees asked for broccoli-plugin ^1.3.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/fastboot-transform/node_modules/broccoli-merge-trees
merge-trees asked for rimraf ^2.4.3 but got 3.0.2
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/fastboot-transform/node_modules/merge-trees
broccoli-stew asked for broccoli-persistent-filter ^1.1.6 but got 3.1.3
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/fastboot-transform/node_modules/broccoli-stew
broccoli-stew asked for broccoli-plugin ^1.3.0 but got 4.0.7
  - in dependencies at /home/karel/gf/ember-mist-components/node_modules/fastboot-transform/node_modules/broccoli-stew
@getflights/ember-gf-components asked for flatpickr https://github.com/getflights/flatpickr/releases/download/4.6.14/flatpickr-4.6.14.tar.gz but got 4.6.14
  - in dependencies at node_modules/@getflights/ember-gf-components
cockpit asked for broccoli-asset-rev ember-cli/broccoli-asset-rev#pull/147/head but got 3.0.0
  - in devDependencies at .
ember-basic-dropdown asked for ember-style-modifier ^0.7.0 but got 0.8.0
  - in dependencies at node_modules/ember-basic-dropdown
cockpit asked for ember-power-select pjcarly/ember-power-select#8e5824f4c619852397aa97ad2477dfb69b617cba but got 5.0.3
  - in devDependencies at .
ember-resolver asked for ember-source ^4.8.3 but got 4.4.4
  - in peerDependencies at node_modules/ember-resolver
Your node_modules are messed up.

Well looks like it’s a mess

cockpit = our app

@getflights/<name> are our addons

@getflights/ember-mist-components is the addon that causes issues