If I get the warning \"Warning: PropTypes has been moved to a separate package.\" How can I locate which npm package is still using it? The warning doesnt offer any details
React deprecated the usage of propTypes
from their main package so you can't use React.PropTypes
. When you use React.PropTypes
it gives you a warning but when you use propTypes
from prop-types
package you are good.
That's It :)
You can use this knowledge to find the list of npm packages which are using it through the following command.
find ./node_modules -type f -print0 | xargs -0 grep 'PropTypes' | cut -d/ -f3 | sort | uniq | xargs -I{} grep -L 'prop-types' ./node_modules/{}/package.json
The above command will find all the npm packages having PropTypes
word present in any of their files, then it looks into the package.json
file of that package to check whether the prop-types
package is included or not. If prop-types
package is missing then it prints the path of that package.
PS: I'm no bash expert so I've taken little help from this serverfault answer. (To find the unique npm packages containing the PropTypes
word)
PPS: The answer assumes that you are using a Unix machine.
This is just an idea so might not be that useful or there would be a better solution but you can use npm ls
command to get the dependency tree. Then you can locate the packages that depends on react but not prop-types. This is sort of a manual solution and might be a better one.
More info about npm ls
here
Synopsis
npm ls [[<@scope>/]<pkg> ...] aliases: list, la, ll
Description
This command will print to stdout all the versions of packages that are installed, as well as their dependencies, in a tree-structure.