Since upgrading to 2.18 I am getting this deprecation warning:
DEPRECATION: An addon is trying to access project.nodeModulesPath. This is not a reliable way to discover npm modules. Instead, consider doing: require("resolve").sync(something, { basedir: project.root }). Accessed from: NPMDependencyVersionChecker (/Volumes/Home/Sites/searchapp/node_modules/ember-cli-document-title/node_modules/ember-cli-version-checker/src/npm-dependency-version-checker.js:11:32)
I found this thread about it which recommends doing:
npm ls ember-cli-version-checker
And seeing what has the old dependency. As it turns out, there are alot of addons I have installed that have the dependency:
All modules that have this error user ember-cli-babel 5 and just need to upgrade to addon to en newer ember-cli that uses ember-cli-babel 6. So you can try to run ember-cli-update on the modules involved and make PR’s .
Is there any information anywhere discussing the architectural direction/decision for this? I am not criticizing the decision, just looking for information. It is handy having the Ember CLI tool providing this information rather than having to do this lookup ourselves - what is the reason it is going to stop being provided?
The change was made in PR 7401. You can read the discussion there, but the tl;dr is that it’s not not correct to assume there is such a thing as single nodeModulesPath. Node’s resolution algorithm lets you have many node_modules directories. ember-cli was being weird by trying to insist on having a single one, and that broke things like yarn workspaces.
How exactly you should use resolve depends on what you’re trying to do. If your addon has a direct dependency on some other package and you want to find it, you can just do a plain require.resolve (as provided by node standard library).
ember-cli-dependency-checker is doing something different, because it’s not looking for it’s own dependencies, it’s looking for its parent’s dependencies, so it needs to resolve them relative to its parent’s directory, not it’s own. That is where the resolve npm package comes in and why it is sometimes needed.
I should add: nodeModulesPath was not a public API, which is why changing it didn’t involve an RFC. But even for private APIs, if we know they’re in active use we issue deprecation warnings until the next LTS release, rather than immediately break them.