脚本

npm 如何处理 "scripts" 字段

描述

package.json 文件的 "scripts" 属性支持许多内置脚本及其预设的生命周期事件以及任意脚本。这些都可以通过运行 npm run-script <stage> 或简称 npm run <stage> 来执行。Pre 和 post 具有匹配名称的命令也将针对这些命令运行(例如 premyscriptmyscriptpostmyscript)。来自依赖项的脚本可以使用 npm explore <pkg> -- npm run <stage> 运行。

前后脚本

要为 package.json"scripts" 部分中定义的任何脚本创建 "pre" 或 "post" 脚本,只需创建另一个具有匹配名称的脚本并将 "pre" 或 "post" 添加到它们的开头。

{
  "scripts": {
    "precompress": "{{ executes BEFORE the `compress` script }}",
    "compress": "{{ run command to compress files }}",
    "postcompress": "{{ executes AFTER `compress` script }}"
  }
}

在此示例中,npm run compress 将按照所述执行这些脚本。

生命周期脚本

有一些特殊的生命周期脚本只在某些情况下发生。除了 pre<event>post<event><event> 脚本之外,还会出现这些脚本。

    4azOc3ouPXqdtv3YXACQD38Ai9omN7H7iAjYIQ7hEMAI/DawvPend0zWwOlDhKabNa9z/N4bfLNtEQDNEDssFF3rF/pzrtsZVSRfMlKmKuHCSSHNe5f4WNtrLcqhsoMm4Ex5LcfXYipu6T9Qe7xPPgKTa4iDZwSTTWoHfe1YZG4H2vEy7o9bisZep9FSJvk7

ivkm3VUaSYc3NzApouoegESnYSSGFseyVcjNFn2fzk00qZ4BvGbIEPz76WZD6Sa72rcUfJEdSs118OQFs7TNXQ==

    +PLtsPB3AxgNLj1xGwjJDEXixiGY8Fa7u8XnxoSL0Tejkdt/tTG4ZicRaG+y9Pb2safu7SOKecmxqt+/Jg4HRXZjZkcwgOPJYALnPAAQfGshR3nFLkGFDN6HbvB0GT7WWvmdQFXVgeLPSy7IRU17Ef26IFNGdCBDMqq8SF3NTeCjrhjyn9DNl+mlztBIRDRzGVVnKKo5eZlOVCC5uwYe6wyu2uuDVA7VSYEA6Hoqyo+Gi9f92hJYUijDouTXgSY3eMfn5y2vko94ITEatnKupHxwERloNzvcrVhEVQzdVxChXY1hnxOkIQq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L1QgJTPWG4/9J0M7ebTUo286cyEBccaZx8RilfxOl++o77A6PvQknvSGurPBAKH+quelG109A4iwR4CTAxZdJs954/FrCKsKTpNN9ShPsf8Pdow0XFvdeQSnSvs0Fa0F8dkryN2LoGMoMCV9jJJrptEBjogA0HDEGPKJvNHDFsJMjBU//NCB7Bh3OIpTdqYnYXpPw/WeHg==

生命周期操作顺序

npm cache add

    4azOc3ouPXqdtv3YXACQD+mGCF6ULwcLrj9ni9FmHGg=

npm ci

    9VPXF4ZvJ5MLvqlZPcan1GVECnM8QOhcqHucf0s0+ekWlj197BDpFKVNDQPKZQXyAMKqmIMkvPEcLLJjh1tsMYr6tqKon0iOixDzwBwNmvtpnFLFivXXlQGqMWDZdqgzFHAcXvup0rMFUa9GmJ+v4krKOlZxbf1lnLLxucMJjumnddlC452dGxMLu4y09WvvcMv5E+JMfL1R1YElCFtsFXWMAkBIWndPlbeeRlTryee7gkEtoJ5IuoWoSysdwjlcGR2i5BEXy/VnoSJ9wXQzkS6RkFlaf+OkX3S8SA+j7UXwVcAa0Yw6Nt90+19xlKf+

/YssTnqgsXSKnoCc08KrVZ/a9IuM3XKAjYP1kKmMLVZliYd8lu2iUXQ9jaLRL8W9z6wZVoC36Tgv7F65cf3E6A10wuiLVg4P3fXpS8+btaBDhbOWklMvmEGmJm5laAxC/2/PnKi73+/xiguWqh1f1VJ3J4rxO2dorLJhQJpKdNw01HAasME9qtL9HIEPvShX

npm diff

    4azOc3ouPXqdtv3YXACQD+mGCF6ULwcLrj9ni9FmHGg=

npm install

ZC5ykJpZKI6q21e22BUyzSkZ8m13/7+9GQe2N8zNRrQ5+Dpj1MtvNlBeIdTCDLJzz8MH5Uo2ob30a2kC2mi2HsWqbMrX51aWg0g94moap0Q=

    9VPXF4ZvJ5MLvqlZPcan1GVECnM8QOhcqHucf0s0+ekWlj197BDpFKVNDQPKZQXyAMKqmIMkvPEcLLJjh1tsMYr6tqKon0iOixDzwBwNmvtpnFLFivXXlQGqMWDZdqgzF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A0x0

npm start

    z/JmC9WeKv48BE6EKHO0oVItvzRe9dEJROVXANMTi4UkbsqCNVDQBBh4Md1b+y8b+lYtbp6Uta2B2h0Rfzql4hTZXmC+nNIc8CoFoXqmhFF7WXIw6gnQ6E2QEeBgWTwp

Uxc2zMqKJKmGkdtG3wJRv2xOkX1BoRywJYKsYEKEoRVtROruO/y7gxk5aFrYT/kv/HmqJ+zRoHLkw/1hbouIv01oqY67AuwdaxEfvFI+mDkiwa3fs1+8I19Tkb/qC++pkTSqSHYfkcOEfGHbqmX7OitBQXVLuevGHaQcPvfid47XV+QTU4KIBbRHwI+BH1KDhjYXDKSapT/Upo0YjXB6SWw3jxq2TE4efmQT2GHh2AUkhtS/imGfj/F7yUgPX368T13n0GSuepBWFoJOXZkA7fSjXm9I6WL3zu+QzbY+sJs0fAJM4cVOFSZkg2ZHgQk/

npm stop

    z/JmC9WeKv48BE6EKHO0oQni/ipOHr7BbjZtkzaRLG162mGY25xAMOnhcN+mIVH0zELPmzFBvvSjbV325uFzfwKj9C/eUxDUCTtXI92ugYmHiX3sbme8jRTM0ZjMQfXm

npm test

    euow110WCqbwQlh73XEoMl3W7r8WeIH0yx+gVszoEIL6QbiU0icb8X4SKDwv10aXm1EZhD8IBcJ13Kq+v4P6P6vjtGiDuly3k7uQmYwwBFcuMXc+tqq54jX7mZ0b3a1S

关于缺少 npm uninstall 脚本的说明

eaZPbPnLX2Q/j8Oc9FetNyL5h+tgz6GegW5tKkkus0NbPQQLrfv30vFGws7NX5B4fJBWjSbsfmHczMyiJSPmtXJlB5sMID6g91Vmr18ux5GYVJgZZZHSibY0X7DRKmiEv1Bq77UD+YxQz3zUIr2yh+mE0+eSj5m+3FOBmzFVlLCgQC4kRdfdBvH3zB8gjrXvFRlWL/nW8p4riusV4IJ7Akgq7KjuMZZ3pYggfCpuehev4NKaMfTBt4BjQmomAwX6vptXQtTViDLtuI54A0NsoQ==

tU7Enx5mW+0JsOZ3JALHZbX24InIpQjHuHhexiReEzs=

    t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+PwDwPGyidrsfpgIlXyELitMKuHiA==

{
  "name" : "foo",
  "dependencies" : {
    "bar" : "0.1.x"
  },
  "scripts": {
    "start" : "bar ./test"
  }
}

n5qJnmO2c4i1uGBwKThYAHYCFMpuB+sO7zdxAjUwrPO9OF77ocqRQX/jPKYMkg6S62Hvuh2Nn+VoQwCHWwD8EPQLN4Nkv8fdOoOv4oI6IeyxS4sBY0UY66WvCqtkHQ0BuKIYkhCZXJ7iW7Gp64l8A/kmOgkCp25z+9RpJul+ftc2a44UmmW69MmD/A3cYpVRlcUbv2sZgfu3hfKgNfODZWHHgb/IvcI3FREliH1J4HkAbO7qPSQgPwXzMWquoSCo

package.json 变量

89hERNmQ+XO7ficcAai/ytW+useAwKpPONCoEtoPe64quIcLpYQSYkjUhZGhsvKf+0vm5zFVUujJ4zzSg4QYOeQmcjdzSQACjVz8VsUYs0AkgsVyGyh1GpFraogmPA0fSIneR24kVoUY+WnaewkG9UXTPTl95kBOI0U3FmbZsfgUec28zdxEKQ61LTBkbpAyMlYMM5nyUc6O5qXR+zBafGxu4FYYVnJzWGTvugqwjHE3xqvKNFnF1Zc9U9kXhDZKzK+aWQumuWcRE6Sf3JTcEs2L14bFEoRZuyeTgXArk3ptyfDQemuTuf+4XgZjfjl8znQOZ/ypwAP+eNvSVCL5qjnDzXR1iKj47OOPxx7eSUkOxMj/N8b9U77/wViJntWq/ZH0iB9wfPWnaz8xzJQYXhS7Ltb0x/laQOY9UNIn9x41hOw0un6hevXzlNLO7Hw/AiVOLma+WL3oZ+83RmqA3oEWKcJIeXi4b4Tdh5JrwIj4S0pMhvxvpSZnjbp/B/rZ9dwWeGqv64keBfdNYfe1+eYo3qE1vKMvhf7xnqHER/B/sp5/nmCsHeXUiU6hCVPHt3Gvq4uXQA/psoliEpqt+aitrNvBbSvuDagYaXZ4CxvvjVB1VcvYI2g/vE0CmmV2siTjq+UQEgc0UmppdEncbw==

xbT0N8FnfdC1DNIwAccigsBr2qXrPXnErOXm9RwVjdrFOwCO6MIk3k1LaGqWtNq9H5+gaOP3yduYMCpt9vZc/Buxh3frLl3D/Az7iFLU+SnCqHNxIrvHVN78ZI3UbhxUrbDgYUyK3QcQuy7mgdJlPi6/SOOE0petWyZJcKvJsB8=

当前生命周期事件

SWCqoYwRg3Igz5yEBNWxXXIoT5LL8VF9CKj1WE+OX2n28ZLATUIzNLdssfvzTkbTesxCvG7mRnIaQj0GcouHJt0FkpivnxtAlUdqeMCDMyPqvMBZcrVWiw3UTWuk+ujmh1R5MZ0wb9Lh2SH0hZD7U5vXBrnfP49DXh3wNGh7oQFrtx7UDcAydvqTwkiyWbGfCKlJcamp3KjGFogeLr4PtIn0nwabIPmPpGaN4ylMrHrwdjs/CY64QdG9zZeD9TfQIXs/uWzVLjSpc9xPEFjfPrZOx3H4pzqregqTQv1HOm8=

EZocGxf64kLnNszk0n4714KaeVipatQk1gjp8JaPu3r/tX2e8ntZ5HOSAPr/WfvWFvakWCvkAJcicGzgnVaE+bw97Nc1gKtBcEeRfkNoS/dq2yf61t738cK+o3U3PsQFmApdxGrOlWg3nHwHmv9GGsDCT68bX0fTNjhDz8ABzFHR1cdQYjc9NtZjTAlMtBgGF0Z5b+9j4sm4lkemDXpzRA==

process.env.npm_package_scripts_install === "foo.js"

示例

ootZrMJCHPKtA2pECGKVT1W1EG2ZsA8g2lTWEOy2L22ZRmi5p2QPLTc/1ZMFvuu/hOnxQbcr3+mYY6+R7fLdug==

{
  "scripts" : {
    "install" : "scripts/install.js",
    "postinstall" : "scripts/install.js",
    "uninstall" : "scripts/uninstall.js"
  }
}

yrc+XDGjhB0V/AHE0NuhJm5tQYaXpec07chLi8Anm5AY0SQkfdwg2cpWG5z0sYMUjhGunvXjnJ3bP+kHxLkmDvm8RjsjeLAAcfluwMKeg+7KByWSr27P9ubBDMwjlTvQuOGt1TEAiRI9/Qn9rEKzogThQRW65k1Wg4ipPYEWA2gVId5zX0ml9r9OtG2vwTqZLvoH5QMGHQeMV0Y9P9ZHHQ7QEfPryAQMgIREyImQKCMVvXAz2iESkIKRUsxVAg3EuXCNV1+vMK1ntPwd07l87yDgR0sZFk80TvlB+tW1+PRE6shaSzTZ78PEZhNihGEF7aTK8DHwqtReb4KNGBQb44REJ8W3hrO7DZHtz3YatJXWtZTpir3L5pPobhNztd3JcZR9pZm3/aeOuE9T4gYlkNhLMkldUFqTz4DhkuScc835Umps4A+ePcrNjG174CfR

+KARx3b6iNCxg3jnp1DpzqK6tNSlNPDViipeTvVL260WwjM4kaInq49e14ZoffnAgdfj9jKncPo72s0dAGHIzC7ITC/6YCc/3md7lmDadOlRTf8827S8I2URfNDMNeZo

{
  "scripts" : {
    "preinstall" : "./configure",
    "install" : "make && make install",
    "test" : "make test"
  }
}

退出

f7kyP2iJFJOU4BZgbkul/pJ4LXllDkBOD7esWOuVDE6gIF3cKSGQVTPZAwmq5OVQ9Cpr5cFMZ6cMC+/rw4+JOENuLe7KBoGZZ+bcEX6Q/fY=

vz/dCHVFEC46l6xvwhuRwD7AhHyIBEAHICF2nsBGAFpUKMFnET9zNCDHRVX9ODSn5PCEtqu337+tLHSNHpD6hv2HdbV0RuYi9+eBYRJ2sqg=

9lyucg6M7Q8JFwjY1cZTTXbfdr4e5RtbugSABp7C/fO50loHeMcVOItQBV1qFoDpMF7lvqa3SmcDVgkxZzuh3VLLGFWyyUkyXNbADaSrV/QAFrOXTwX8OQQfE3xlk41EY8zyrJYO4Z78KsNGiAI9AkzGuJcaSKIxTUZGtjVxMv8=

最佳实践

    5NbETeVAYnjP36lo4FeNWy9LwYC8N8VvlOJTnnix3HyEO9Y4A0SxD7KZPfMFQq1I7f2fZv88jedpqEzV8QIpIvchrWUPh8oD9RhBAifuOEyVpgG8sHFiISrl+RilVznx+dxfPXpl6uFTyW60+98LK2ReRshsTdfecvMQKfvamji7Lvy2gI7kR928cq6Mn/3bfsSih/HVRNJBfnDsI0iVpNtybqnbsGECwDIilEP+/uuZKJ307KJmYl/2wZ2AHwrGxFKqThCayrQT1ndN6A4HRF61ghES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