loading...

Force to Use yarn

kojikanao profile image Koji (he/him) ・1 min read

package.json

{
  "name": "nonpm",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "engines": {
    "npm": "⚠️please-use-yarn⚠️",
    "yarn": ">= 1.17.3"
  },
  "keywords": [],
  "author": "koji",
  "license": "ISC",
  "dependencies": {
    "uuid": "^8.1.0"
  }
}

.npmrc

https://docs.npmjs.com/misc/config#engine-strict

engine-strict = true
$ npm i
npm ERR! code ENOTSUP
npm ERR! notsup Unsupported engine for nonpm@1.0.0: wanted: {"npm":"⚠️please-use-yarn⚠️","yarn":">= 1.17.3"} (current: {"node":"12.10.0","npm":"6.10.3"})
npm ERR! notsup Not compatible with your version of node/npm: nonpm@1.0.0
npm ERR! notsup Not compatible with your version of node/npm: nonpm@1.0.0
npm ERR! notsup Required: {"npm":"⚠️please-use-yarn⚠️","yarn":">= 1.17.3"}
npm ERR! notsup Actual:   {"npm":"6.10.3","node":"12.10.0"}

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/koji.kanao/.npm/_logs/2020-05-22T01_52_57_062Z-debug.log

However, still, we can install a package 🤣🤣🤣

$ npm i uuid
npm WARN nonpm@1.0.0 No description
npm WARN nonpm@1.0.0 No repository field.

+ uuid@8.1.0
updated 1 package and audited 1 package in 0.663s
found 0 vulnerabilities

Tried another command.

$ npm audit

                       === npm audit security report ===

found 0 vulnerabilities
 in 1 scanned package

Also check out 👇!

thanks @patarapolw

Discussion

pic
Editor guide
Collapse
patarapolw profile image
Pacharapol Withayasakpunt

npm preinstall is broken, unlike yarn preinstall, as it is not run before npm install xxx (only before npm install), so I created a custom install command just to be sure.

Collapse
kojikanao profile image
Koji (he/him) Author

nice, thank you for sharing the info!