project-env
v1.1.6
Published
锁定和切换项目使用的npm/yarn/pnpm版本和node版本
Downloads
19
Maintainers
Readme
Porject Environment
overview
- Lock Node.js Version
- Lock PackageManager Version (npm/yarn/pnpm)
useage
- install n
npx project-env node=20.11.1 pnpm=8.15.4
advanced
"scripts": {
"project-env": "npx -y project-env node=18.19.1 pnpm=8.15.4",
"preinstall": "npx -y project-env onlyAllow",
"prestart": "npx -y project-env dev",
"dev": "npm run start",
}
project-env dev
"scripts": { "dev": "npx project-env dev && echo hello-dev" }
- run
npm run dev
auto switch node versions
default Options
node=20.11.1
pnpm=8.15.4
npmMirror=https://registry.npmmirror.com/
nodeMirror=https://npmmirror.com/mirrors/node
debug=false
engines=true
设置为false则不切换node版本
features
// Expected environment
const wanted = getWanted()
// Current environment
const current = whichPmRuns()
// Config .gitignore
const lockFileSuccess = await gitignoreLockfile(wanted.name)
// Config .npmrc
const npmrcSuccess = await npmrcSettings()
// Config package.json
const packagejsonSuccess = await packageJson()
// Check Node.js version
const nodeSuccess = await checkNode(wanted, current)
// Check PackageManager version
const pmSuccess = await checkNpm(wanted)