Reputation: 419
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
.
Upvotes: 15
Views: 8672
Reputation: 61
Projects using npm will have a package-lock.json
file while projects using yarn will have a yarn.lock
file.
Upvotes: 3
Reputation: 3969
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'
Upvotes: 10
Reputation: 3675
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.
Upvotes: 19