npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Confused about dependency version resolution priority

I’m having an issue where the wrong version of babel-core is ending up in the root node_modules folder. Running npm ls babel-core shows:

my-package@4.0.0 /Users/<username>/projects/my-package
├─┬ build-scripts-core@1.0.3
│ ├── babel-core@7.0.0-bridge.0
│ └─┬ babel-plugin-emotion@9.2.6
│   └─┬ babel-core@6.26.3
│     └─┬ babel-register@6.26.0
│       └── babel-core@6.26.3  deduped
└─┬ build-scripts-external-preset@1.0.3
  ├─┬ build-scripts-jest@1.0.3
  │ ├── babel-core@7.0.0-bridge.0
  │ └─┬ jest-cli@23.4.2
  │   ├─┬ jest-config@23.4.2
  │   │ └── babel-core@6.26.3  deduped
  │   └─┬ jest-runtime@23.4.2
  │     └── babel-core@6.26.3  deduped
  └─┬ build-scripts-webpack@1.0.3
    └── babel-core@7.0.0-bridge.0

The version in the root folder node_modules folder is 6.26.3 but I would have expected it to be 7.0.0-bridge.0 given that any package bringing it in is beneath one bringing in the higher version, but not knowing exactly what order the packages are installed in, I’m not sure if this assumption is correct or not.

Assuming npm is behaving correctly, other than specifying the desired version in my-package's package.json, is there anyway I can have the version specified in build-scripts-core's package.json installed at the root?

I have complete control to update the build-scripts-xxx packages, but I do not want the dependency details to leak outside if possible. The reason for this is the whole point of these packages is to abstract away the tools used in maintaining the projects in a similar way that create-react-app or kcd-scripts does.