"can-globals" namespace error after upgrading to 4.x

I’m getting the following error after upgrading to can 4, and am not quite sure how to proceed:

Error: You can't have two versions of can-globals, check your dependencies
	    at Object.eval (http://localhost:8082/node_modules/can-attribute-observable/node_modules/can-globals/can-globals-instance.js:10:8)
	    at eval (http://localhost:8082/node_modules/can-attribute-observable/node_modules/can-globals/can-globals-instance.js:15:4)
	    at eval (http://localhost:8082/node_modules/can-attribute-observable/node_modules/can-globals/can-globals-instance.js:15:98)
	Evaluating http://localhost:8082/node_modules/can-attribute-observable/node_modules/can-globals/can-globals-instance.js
	Evaluating http://localhost:8082/node_modules/can-attribute-observable/node_modules/can-globals/global/global.js
	Evaluating http://localhost:8082/node_modules/can-attribute-observable/node_modules/can-globals/document/document.js
	Evaluating http://localhost:8082/node_modules/can-attribute-observable/behaviors.js
	Evaluating http://localhost:8082/node_modules/can-attribute-observable/can-attribute-observable.js
	Evaluating http://localhost:8082/node_modules/can-stache-bindings/can-stache-bindings.js
	Evaluating http://localhost:8082/node_modules/can-connect/can/tag/tag.js

Here’s my package.json:

  "dependencies": {
    "bootstrap": "^4.0.0-beta.2",
    "can-component": "^4.0.4",
    "can-connect": "^2.0.4",
    "can-define": "^2.0.3",
    "can-queues": "^1.0.1",
    "can-route": "^4.1.1",
    "can-route-pushstate": "^4.0.4",
    "can-set": "^1.5.2",
    "can-stache": "^4.2.3",
    "can-stache-converters": "^4.0.2",
    "can-stache-route-helpers": "^0.1.4",
    "can-view-autorender": "^4.0.0",
    "can-zone": "^0.6.6",
    "d3": "^4.12.2",
    "dagre-d3": "^0.6.0",
    "datatables.net": "^1.10.16",
    "datatables.net-bs": "^1.10.16",
    "datatables.net-buttons": "^1.5.0",
    "datatables.net-buttons-bs": "^1.5.0",
    "done-autorender": "^2.1.0",
    "done-component": "^2.1.0",
    "done-css": "^3.0.0",
    "done-serve": "^2.0.0",
    "dropzone": "^5.2.0",
    "flat": "^4.0.0",
    "font-awesome": "^4.7.0",
    "generator-donejs": "^2.1.0",
    "highcharts": "^5.0.14",
    "humanize-plus": "^1.8.2",
    "intellify-timezone-js": "1.0.1",
    "moment": "^2.21.0",
    "popper.js": "^1.12.6",
    "steal": "^1.9.1",
    "steal-less": "^1.2.0",
    "steal-stache": "^4.1.0"
  },
  "devDependencies": {
    "can-debug": "^1.0.0",
    "can-fixture": "^2.0.3",
    "donejs-cli": "^2.1.0",
    "funcunit": "^3.2.0",
    "steal-conditional": "^1.0.0",
    "steal-qunit": "^1.0.1",
    "steal-tools": "^1.11.5",
    "testee": "^0.7.0"
  }

Can you use steal._traceData to see what is importing the older global?

then expand your older global (I’m showing the newer one):

You should be able to walk up the parent dependencies until you find what your code is importing that is importing can-globals.

It’s likely you are importing something in can-util that is now replaced elsewhere. Once you let me know what it is, I’ll tell you how to update the deps.

Here’s the filtered _traceData output (JSON.stringify(Object.entries(System._traceData.parentMap).filter(function(e) { return e[0].startsWith('can-global'); }))):

[
  [
    "can-globals@1.0.0#document/document",
    {
      "can-view-import@4.0.2#can-view-import": true,
      "can-stache@4.2.3#can-stache": true,
      "can-globals@1.0.0#can-globals": true,
      "can-dom-mutate@1.0.3#-util": true,
      "can-stache@4.2.3#src/html_section": true,
      "can-view-target@4.0.1#can-view-target": true,
      "can-util@3.11.2#dom/frag/frag": true,
      "can-util@3.11.2#js/base-url/base-url": true,
      "can-util@3.11.2#dom/fragment/fragment": true,
      "can-dom-events@1.1.1#helpers/util": true,
      "can-dom-events@1.1.3#helpers/util": true,
      "can-component@4.0.4#can-component": true,
      "can-view-model@4.0.1#can-view-model": true,
      "can-event-dom-radiochange@2.1.0#can-event-dom-radiochange": true
    }
  ],
  [
    "can-globals@1.0.0#is-web-worker/is-web-worker",
    {
      "can-route@4.1.1#can-route": true
    }
  ],
  [
    "can-globals@1.0.0#is-browser-window/is-browser-window",
    {
      "can-route@4.1.1#can-route": true,
      "can-globals@1.0.0#can-globals": true,
      "can-dom-events@1.1.1#helpers/util": true,
      "can-dom-events@1.1.3#helpers/util": true
    }
  ],
  [
    "can-globals@1.0.0#can-globals",
    {
      "can-dom-mutate@1.0.3#node": true,
      "can-dom-mutate@1.0.3#can-dom-mutate": true,
      "can-view-callbacks@4.0.1#can-view-callbacks": true
    }
  ],
  [
    "can-globals@1.0.0#can-globals-instance",
    {
      "can-globals@1.0.0#can-globals": true,
      "can-globals@1.0.0#is-web-worker/is-web-worker": true,
      "can-globals@1.0.0#is-browser-window/is-browser-window": true,
      "can-globals@1.0.0#document/document": true,
      "can-globals@1.0.0#global/global": true,
      "can-globals@1.0.0#location/location": true,
      "can-globals@1.0.0#mutation-observer/mutation-observer": true,
      "can-globals@1.0.0#is-node/is-node": true,
      "can-globals@1.0.0#custom-elements/custom-elements": true
    }
  ],
  [
    "can-globals@1.0.0#global/global",
    {
      "can-globals@1.0.0#can-globals": true,
      "can-dom-mutate@1.0.3#can-dom-mutate": true,
      "can-view-callbacks@4.0.1#can-view-callbacks": true,
      "can-globals@1.0.0#document/document": true,
      "can-util@3.11.2#js/import/import": true,
      "can-globals@1.0.0#location/location": true,
      "can-globals@1.0.0#mutation-observer/mutation-observer": true,
      "can-globals@1.0.0#custom-elements/custom-elements": true,
      "can-util@3.11.2#js/base-url/base-url": true,
      "can-util@3.11.2#js/global/global": true,
      "can-ajax@1.1.4#can-ajax": true
    }
  ],
  [
    "can-globals@1.0.0#location/location",
    {
      "can-globals@1.0.0#can-globals": true,
      "can-route@4.1.1#src/hashchange": true
    }
  ],
  [
    "can-globals@1.0.0#mutation-observer/mutation-observer",
    {
      "can-globals@1.0.0#can-globals": true,
      "can-dom-mutate@1.0.3#can-dom-mutate": true,
      "can-view-target@4.0.1#can-view-target": true
    }
  ],
  [
    "can-globals@1.0.0#is-node/is-node",
    {
      "can-globals@1.0.0#can-globals": true,
      "can-globals@1.0.0#is-browser-window/is-browser-window": true
    }
  ],
  [
    "can-globals@1.0.0#custom-elements/custom-elements",
    {
      "can-globals@1.0.0#can-globals": true
    }
  ],
  [
    "can-globals@1.0.0#can-globals-proto",
    {
      "can-globals@1.0.0#can-globals-instance": true
    }
  ],
  [
    "can-globals@1.0.1#document/document",
    {
      "can-attribute-observable@0.1.0#behaviors": true
    }
  ],
  [
    "can-globals@1.0.1#global/global",
    {
      "can-attribute-observable@0.1.0#behaviors": true,
      "can-globals@1.0.1#document/document": true,
      "can-globals@1.0.1#mutation-observer/mutation-observer": true
    }
  ],
  [
    "can-globals@1.0.1#mutation-observer/mutation-observer",
    {
      "can-attribute-observable@0.1.0#behaviors": true
    }
  ],
  [
    "can-globals@1.0.1#can-globals-instance",
    {
      "can-globals@1.0.1#document/document": true,
      "can-globals@1.0.1#global/global": true,
      "can-globals@1.0.1#mutation-observer/mutation-observer": true
    }
  ],
  [
    "can-globals@1.0.1#can-globals-proto",
    {
      "can-globals@1.0.1#can-globals-instance": true
    }
  ]
]

oh, everything has either can-global 1.0.0 or 1.0.1? Have you deleted node_modules, your package-lock.json, and re-installed?

Removing the package-lock.json and reinstalling did the trick. When I ran the npm upgrades I’d naively assumed package-lock would update appropriately.

Thanks!

We probably should delete it. cc @phillipskevin

We could have donejs upgrade delete the package-lock if it’s not doing that already. Is that what you mean @justinbmeyer?

To be clear, I didnt run donejs upgrade; I went through the upgrade doc and manually ran each npm install foo@latest command.

Ok, we’ll definitely add a note to the migration guide about this.