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

my-trusted-test

v1.0.5

Published

it's a test at NPM scripts

Downloads

7

Readme

my-trusted-test

my-trusted-test 是一个颜色 npm 包 生命周期的各个阶段执行 npm 生命周期脚本。npm script 是如何触发这些生命周期事件的?

Scripts 生命周期: 此软件包包含以下npm生命周期脚本:

  • preinstall:在软件包安装开始之前触发。 "preinstall": "echo 'Trust preinstalling!' # (Running preinstall script)"
  • postinstall:在安装软件包后立即触发。 "postinstall": "echo 'Trust Installed!' # (Running postinstall script)"
  • preuninstall:在卸载软件包之前触发。 "preuninstall": "echo 'Trust preuninstalling!' # (Running preuninstall script)"
  • postuninstall:卸载软件包后触发。 "postuninstall": "echo 'Trust postuninstalling!' # (Running postuninstall script)"
  • prepare:在两种情况下触发:在本地安装软件包后(而不是通过注册表)和软件包打包和发布之前(例如,在npm publish或npm pack期间)。 "prepare": "echo 'Preparing Trust!' # (Running prepare script)"

安装使用

--foreground-scripts: 查看脚本执行情况和输出日志;

npm 7 以上的版本使用,出于安全考虑在前台控制台中,可能不会输出脚本执行日志,所以需要使用命令标识 --foreground-scripts 方便在前台的控制台中观察执行情况和输出日志。 npm i --foreground-scripts my-trusted-test

--ignore-scripts:忽略scripts生命脚本执行;

npm install --foreground-scripts --ignore-scripts my-trusted-test

禁止运行scripts的生命周期脚本的重要醒

在 npm 的包中,发现了很多恶意软件都是利用了 install scripts 的特性,这些脚本通常在未经过用户确认的情况下执行的。 因此允许 install scripts 可能会带来一些风险。

  • 修改和窃取数据: 可以利用 scripts 中的生命周期更改或者窃取用户可访问的文件;
  • 安装恶意软件:利用 scripts 中的生命周期特性,可以在未经过用户同意的情况下下载和安装其他恶意软件包或软件;
  • 未经授权访问系统资源: 利用 scripts 中的生命周期特性,可以利用 npm 的安装功能来执行一些恶意操作,例如访问系统资源、修改系统配置等。

建议

  • 在安装软件包的使用使用 --ignore-scripts: 这个命令选项可以避免 npm 执行安装脚本,从而避免可能存在的恶意软件。 npm install --ignore-scripts XXX
  • 继续禁用脚本: 可以在 .npmrc 文件中设置全局配置,以始终放置在npm安装期间执行脚本。 ignore-scripts=true