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
.
Projects using npm will have a package-lock. json file while projects using yarn will have a yarn.
Yarn can consume the same package. json format as npm, and can install any package from the npm registry. This will lay out your node_modules folder using Yarn's resolution algorithm that is compatible with the node. js module resolution algorithm.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With