user3126529
user3126529

Reputation: 419

How to tell if a project uses Yarn

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

Answers (3)

Surajan Shrestha
Surajan Shrestha

Reputation: 61

Projects using npm will have a package-lock.json file while projects using yarn will have a yarn.lock file.

Upvotes: 3

Andrew
Andrew

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

Rob Bell
Rob Bell

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

Related Questions