npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-env-strict

v2.3.0

Published

检测本地node、npm版本是否满足项目环境要求,同时检查package-lock.json文件提交时版本是否改变

Downloads

7

Readme

✨ node-env-strict

node-env-strict

主要功能:

  • 检测本地 node、npm 版本是否满足项目环境要求
  • 检测 package-lock.json文件提交时,文件版本是否改变(防止 package-lock.json 版本不同引发的一系列问题)建议配合 husky 使用
  • 限制 package-lock.json 文件版本使用指定版本

📦 安装

安装

npm i -D node-env-strict

🔨 使用

直接使用:

npx node-env-strict                    检测package-lock.json文件提交时,文件版本是否改变
Options:
  -c,--check-engine                    检查当前的node、npm环境是否满足package.json中engines的限制
  -r,--restrict-version 2              限制具体的package-lock.json文件版本,可选版本为:[1,2,3]

检查当前的 node、npm 环境,是否满足项目环境要求

package.json增加配置engines,指定nodenpm版本范围

"engines": {
  "node": "7.10.0",
  "npm": "4.2.0"
}

指令:

npx node-env-strict -c

效果:

check-engine

指定 package-lock.json 文件版本

npx node-env-strict -r=2

效果:

restict-version

🌟 推荐配合 husky 使用

安装 husky 后执行指令:

npx husky add .husky/pre-commit "node-env-strict"

或者编辑.husky/pre-commit

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
// 增加
npx node-env-strict

🔔 其他

lockfileVersion 和 npm、node 版本对应信息

| lockfileVersion | npm | node | 备注 | | --------------- | -------------- | ----------- | ---------------------------------------- | | none | < 5.0 | < 8.0 | 未提供版本:来自 npm 5.0 之前的 npm 版本 | | 1 | 5.0 ~ 6.0 | 8.0 ~ 14.20 | | | 2 | 7.0 (向下兼容) | >= 15.0.0 | npm 7.0 向下兼容 lockfileVersion 1 | | 3 | 7.0 | >= 15.0.0 | npm 7.0 (不向下兼容) |