How does one know if a project uses Yarn or NPM? Both contain a package.json file, although Yarn dependencies contain a file in the folder called yarn.lock.
How does one know if a project uses Yarn or NPM? Both contain a package.json file, although Yarn dependencies contain a file in the folder called yarn.lock.
Both use package.json with the same JSON format, but NPM 5 generates a package-lock.json file, whereas Yarn generates a yarn.lock file.
Both will resolve to populating the node_modules folder with their own resolution algorithms.
I created this shell alias to detect if a project uses npm or yarn.
alias npm_or_yarn='ls yarn.lock &> /dev/null && echo yarn || echo npm'
You can also create an alias to automatically run start using npm or yarn.
alias npm_or_yarn_start='$(npm_or_yarn) start'
Projects using npm will have a package-lock.json file while projects using yarn will have a yarn.lock file.