DEV Community

0xkoji
0xkoji

Posted on

Force to Use yarn

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"
  }
}
Enter fullscreen mode Exit fullscreen mode

.npmrc

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

engine-strict = true
Enter fullscreen mode Exit fullscreen mode
$ 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Tried another command.

$ npm audit

                       === npm audit security report ===

found 0 vulnerabilities
 in 1 scanned package

Enter fullscreen mode Exit fullscreen mode

Also check out 👇!

thanks @patarapolw

Top comments (2)

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
 
0xkoji profile image
0xkoji

nice, thank you for sharing the info!