"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[8851],{9613:(e,t,n)=>{n.d(t,{Zo:()=>u,kt:()=>c});var l=n(9496);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,l)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e,t){if(null==e)return{};var n,l,r=function(e,t){if(null==e)return{};var n,l,r={},a=Object.keys(e);for(l=0;l<a.length;l++)n=a[l],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(l=0;l<a.length;l++)n=a[l],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var p=l.createContext({}),s=function(e){var t=l.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},u=function(e){var t=s(e.components);return l.createElement(p.Provider,{value:t},e.children)},d="mdxType",k={inlineCode:"code",wrapper:function(e){var t=e.children;return l.createElement(l.Fragment,{},t)}},m=l.forwardRef((function(e,t){var n=e.components,r=e.mdxType,a=e.originalType,p=e.parentName,u=o(e,["components","mdxType","originalType","parentName"]),d=s(n),m=r,c=d["".concat(p,".").concat(m)]||d[m]||k[m]||a;return n?l.createElement(c,i(i({ref:t},u),{},{components:n})):l.createElement(c,i({ref:t},u))}));function c(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var a=n.length,i=new Array(a);i[0]=m;var o={};for(var p in t)hasOwnProperty.call(t,p)&&(o[p]=t[p]);o.originalType=e,o[d]="string"==typeof e?e:r,i[1]=o;for(var s=2;s<a;s++)i[s]=n[s];return l.createElement.apply(null,i)}return l.createElement.apply(null,n)}m.displayName="MDXCreateElement"},6910:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>u,contentTitle:()=>p,default:()=>c,frontMatter:()=>o,metadata:()=>s,toc:()=>d});var l=n(1966),r=n(9836),a=(n(9496),n(9613)),i=["components"],o={id:"install",title:"pnpm install"},p=void 0,s={unversionedId:"cli/install",id:"version-8.x/cli/install",title:"pnpm install",description:"\u547d\u4ee4\u5225\u540d\uff1ai",source:"@site/i18n/zh-TW/docusaurus-plugin-content-docs/version-8.x/cli/install.md",sourceDirName:"cli",slug:"/cli/install",permalink:"/zh-TW/cli/install",draft:!1,editUrl:"https://translate.pnpm.io/project/pnpm/zh-TW",tags:[],version:"8.x",frontMatter:{id:"install",title:"pnpm install"},sidebar:"version-8.x/docs",previous:{title:"pnpm add <pkg>",permalink:"/zh-TW/cli/add"},next:{title:"pnpm update",permalink:"/zh-TW/cli/update"}},u={},d=[{value:"TL;DR",id:"tldr",level:2},{value:"Options",id:"options",level:2},{value:"--force",id:"--force",level:3},{value:"--offline",id:"--offline",level:3},{value:"--prefer-offline",id:"--prefer-offline",level:3},{value:"--prod, -P",id:"--prod--p",level:3},{value:"--dev, -D",id:"--dev--d",level:3},{value:"--no-optional",id:"--no-optional",level:3},{value:"--lockfile-only",id:"--lockfile-only",level:3},{value:"--fix-lockfile",id:"--fix-lockfile",level:3},{value:"--frozen-lockfile",id:"--frozen-lockfile",level:3},{value:"--merge-git-branch-lockfiles",id:"--merge-git-branch-lockfiles",level:3},{value:"--reporter=&lt;name&gt;",id:"--reportername",level:3},{value:"--use-store-server",id:"--use-store-server",level:3},{value:"--shamefully-hoist",id:"--shamefully-hoist",level:3},{value:"--ignore-scripts",id:"--ignore-scripts",level:3},{value:"--filter &lt;package_selector&gt;",id:"--filter-package_selector",level:3},{value:"--resolution-only",id:"--resolution-only",level:3}],k={toc:d},m="wrapper";function c(e){var t=e.components,o=(0,r.Z)(e,i);return(0,a.kt)(m,(0,l.Z)({},k,o,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("p",null,"\u547d\u4ee4\u5225\u540d\uff1a",(0,a.kt)("inlineCode",{parentName:"p"},"i")),(0,a.kt)("p",null,"\u4f7f\u7528 ",(0,a.kt)("inlineCode",{parentName:"p"},"pnpm install")," \u4f86\u70ba\u5c08\u6848\u5b89\u88dd\u6240\u6709\u76f8\u4f9d\u5957\u4ef6\u3002"),(0,a.kt)("p",null,"\u5728 CI \u74b0\u5883\u4e2d\uff0c\u5982\u679c lockfile \u5b58\u5728\u4f46\u9700\u8981\u66f4\u65b0\u6642\uff0c\u6703\u4f7f\u5b89\u88dd\u5931\u6557\u3002"),(0,a.kt)("p",null,"\u5728 ",(0,a.kt)("a",{parentName:"p",href:"/zh-TW/workspaces"},"workspace")," \u4e2d\uff0c",(0,a.kt)("inlineCode",{parentName:"p"},"pnpm install")," \u6703\u5b89\u88dd\u6240\u6709\u5c08\u6848\u7684\u76f8\u4f9d\u5957\u4ef6\u3002 \u5982\u8981\u505c\u7528\u6b64\u884c\u70ba\uff0c\u8acb\u5c07 ",(0,a.kt)("inlineCode",{parentName:"p"},"recursive-install")," \u8a2d\u70ba ",(0,a.kt)("inlineCode",{parentName:"p"},"false"),"\u3002"),(0,a.kt)("p",null,(0,a.kt)("img",{src:n(1624).Z,width:"940",height:"472"})),(0,a.kt)("h2",{id:"tldr"},"TL;DR"),(0,a.kt)("table",null,(0,a.kt)("thead",{parentName:"table"},(0,a.kt)("tr",{parentName:"thead"},(0,a.kt)("th",{parentName:"tr",align:null},"\u547d\u4ee4"),(0,a.kt)("th",{parentName:"tr",align:null},"\u6548\u679c"))),(0,a.kt)("tbody",{parentName:"table"},(0,a.kt)("tr",{parentName:"tbody"},(0,a.kt)("td",{parentName:"tr",align:null},(0,a.kt)("inlineCode",{parentName:"td"},"pnpm i --offline")),(0,a.kt)("td",{parentName:"tr",align:null},"\u50c5\u5f9e\u5132\u5b58\u5340\u96e2\u7dda\u5b89\u88dd\u5957\u4ef6")),(0,a.kt)("tr",{parentName:"tbody"},(0,a.kt)("td",{parentName:"tr",align:null},(0,a.kt)("inlineCode",{parentName:"td"},"pnpm i --frozen-lockfile")),(0,a.kt)("td",{parentName:"tr",align:null},"\u4e0d\u66f4\u65b0 ",(0,a.kt)("inlineCode",{parentName:"td"},"pnpm-lock.yaml"))),(0,a.kt)("tr",{parentName:"tbody"},(0,a.kt)("td",{parentName:"tr",align:null},(0,a.kt)("inlineCode",{parentName:"td"},"pnpm i --lockfile-only")),(0,a.kt)("td",{parentName:"tr",align:null},"\u50c5\u66f4\u65b0 ",(0,a.kt)("inlineCode",{parentName:"td"},"pnpm-lock.yaml"))))),(0,a.kt)("h2",{id:"options"},"Options"),(0,a.kt)("h3",{id:"--force"},"--force"),(0,a.kt)("p",null,"Force reinstall dependencies: refetch packages modified in store, recreate a lockfile and/or modules directory created by a non-compatible version of pnpm. Install all optionalDependencies even they don't satisfy the current environment(cpu, os, arch)."),(0,a.kt)("h3",{id:"--offline"},"--offline"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"\u9810\u8a2d\u503c\uff1a",(0,a.kt)("strong",{parentName:"li"},"false")),(0,a.kt)("li",{parentName:"ul"},"\u985e\u578b\uff1a",(0,a.kt)("strong",{parentName:"li"},"Boolean"))),(0,a.kt)("p",null,"\u6b64\u503c\u70ba ",(0,a.kt)("inlineCode",{parentName:"p"},"true")," \u6642\uff0cpnpm \u53ea\u4f7f\u7528\u5132\u5b58\u5340\u4e2d\u53ef\u7528\u7684\u5957\u4ef6\u3002 \u5982\u679c\u5728\u672c\u6a5f\u7121\u6cd5\u627e\u5230\u5957\u4ef6\uff0c\u5247\u5b89\u88dd\u6703\u5931\u6557\u3002"),(0,a.kt)("h3",{id:"--prefer-offline"},"--prefer-offline"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"\u9810\u8a2d\u503c\uff1a",(0,a.kt)("strong",{parentName:"li"},"false")),(0,a.kt)("li",{parentName:"ul"},"\u985e\u578b\uff1a",(0,a.kt)("strong",{parentName:"li"},"Boolean"))),(0,a.kt)("p",null,"\u6b64\u503c\u70ba ",(0,a.kt)("inlineCode",{parentName:"p"},"true")," \u6642\uff0c\u5c07\u4e0d\u6aa2\u67e5\u5feb\u53d6\u8cc7\u6599\u662f\u5426\u904e\u6642\uff0c\u4f46\u5c07\u5f9e\u4f3a\u670d\u5668\u8acb\u6c42\u907a\u6f0f\u7684\u8cc7\u6599\u3002 \u82e5\u8981\u5f37\u5236\u555f\u7528\u5b8c\u5168\u96e2\u7dda\u6a21\u5f0f\uff0c\u8acb\u4f7f\u7528 ",(0,a.kt)("inlineCode",{parentName:"p"},"--offline"),"\u3002"),(0,a.kt)("h3",{id:"--prod--p"},"--prod, -P"),(0,a.kt)("p",null,"pnpm will not install any package listed in ",(0,a.kt)("inlineCode",{parentName:"p"},"devDependencies")," and will remove those insofar they were already installed, if the ",(0,a.kt)("inlineCode",{parentName:"p"},"NODE_ENV")," environment variable is set to production. Use this flag to instruct pnpm to ignore ",(0,a.kt)("inlineCode",{parentName:"p"},"NODE_ENV")," and take its production status from this flag instead."),(0,a.kt)("h3",{id:"--dev--d"},"--dev, -D"),(0,a.kt)("p",null,"Only ",(0,a.kt)("inlineCode",{parentName:"p"},"devDependencies")," are installed and ",(0,a.kt)("inlineCode",{parentName:"p"},"dependencies")," are removed insofar they were already installed, regardless of the ",(0,a.kt)("inlineCode",{parentName:"p"},"NODE_ENV"),"."),(0,a.kt)("h3",{id:"--no-optional"},"--no-optional"),(0,a.kt)("p",null,(0,a.kt)("inlineCode",{parentName:"p"},"optionalDependencies")," \u672a\u5b89\u88dd\u3002"),(0,a.kt)("h3",{id:"--lockfile-only"},"--lockfile-only"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"\u9810\u8a2d\u503c\uff1a",(0,a.kt)("strong",{parentName:"li"},"false")),(0,a.kt)("li",{parentName:"ul"},"\u985e\u578b\uff1a",(0,a.kt)("strong",{parentName:"li"},"Boolean"))),(0,a.kt)("p",null,"\u4f7f\u7528\u6b64\u9078\u9805\u6642\uff0c\u50c5\u66f4\u65b0 ",(0,a.kt)("inlineCode",{parentName:"p"},"pnpm-lock.yaml")," \u8207 ",(0,a.kt)("inlineCode",{parentName:"p"},"package.json"),"\u3002 \u4e0d\u6703\u5c0d ",(0,a.kt)("inlineCode",{parentName:"p"},"node_modules")," \u76ee\u9304\u5beb\u5165\u4efb\u4f55\u6a94\u6848\u3002"),(0,a.kt)("h3",{id:"--fix-lockfile"},"--fix-lockfile"),(0,a.kt)("p",null,"\u81ea\u52d5\u4fee\u5fa9\u640d\u58de\u7684 lockfile\u3002"),(0,a.kt)("h3",{id:"--frozen-lockfile"},"--frozen-lockfile"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"\u9810\u8a2d\u503c\uff1a",(0,a.kt)("ul",{parentName:"li"},(0,a.kt)("li",{parentName:"ul"},"\u975e CI\uff1a",(0,a.kt)("strong",{parentName:"li"},"false")),(0,a.kt)("li",{parentName:"ul"},"CI\uff1a\u7576 lockfile \u5b58\u5728\u6642\u70ba ",(0,a.kt)("strong",{parentName:"li"},"true")))),(0,a.kt)("li",{parentName:"ul"},"\u985e\u578b\uff1a",(0,a.kt)("strong",{parentName:"li"},"Boolean"))),(0,a.kt)("p",null,"\u6b64\u503c\u70ba ",(0,a.kt)("inlineCode",{parentName:"p"},"true")," \u6642\uff0cpnpm \u4e0d\u6703\u7522\u751f lockfile\uff0c\u4e26\u4e14\u5728 lockfile \u8207\u6e05\u55ae\u4e0d\u540c\u6b65\u3001\u9700\u8981\u66f4\u65b0\uff0c\u6216 lockfile \u4e0d\u5b58\u5728\u6642\uff0c\u6703\u4f7f\u5b89\u88dd\u5931\u6557\u3002"),(0,a.kt)("p",null,"\u6b64\u8a2d\u5b9a\u503c\u5728 ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/watson/ci-info#supported-ci-tools"},"CI \u74b0\u5883"),"\u4e2d\u9810\u8a2d\u70ba ",(0,a.kt)("inlineCode",{parentName:"p"},"true"),"\u3002 \u7528\u4f86\u5075\u6e2c CI \u74b0\u5883\u7684\u7a0b\u5f0f\u78bc\u5982\u4e0b\uff1a"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-js",metastring:'title="https://github.com/watson/ci-info/blob/44e98cebcdf4403f162195fbcf90b1f69fc6e047/index.js#L54-L61"',title:'"https://github.com/watson/ci-info/blob/44e98cebcdf4403f162195fbcf90b1f69fc6e047/index.js#L54-L61"'},"exports.isCI = !!(\n  env.CI || // Travis CI, CircleCI, Cirrus CI, GitLab CI, Appveyor, CodeShip, dsari\n  env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI\n  env.BUILD_NUMBER || // Jenkins, TeamCity\n  env.RUN_ID || // TaskCluster, dsari\n  exports.name ||\n  false\n)\n")),(0,a.kt)("h3",{id:"--merge-git-branch-lockfiles"},"--merge-git-branch-lockfiles"),(0,a.kt)("p",null,"Merge all git branch lockfiles. ",(0,a.kt)("a",{parentName:"p",href:"../git_branch_lockfiles"},"Read more about git branch lockfiles.")),(0,a.kt)("h3",{id:"--reportername"},"--reporter=","<","name",">"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"\u9810\u8a2d\u503c\uff1a",(0,a.kt)("ul",{parentName:"li"},(0,a.kt)("li",{parentName:"ul"},"For TTY stdout: ",(0,a.kt)("strong",{parentName:"li"},"default")),(0,a.kt)("li",{parentName:"ul"},"For non-TTY stdout: ",(0,a.kt)("strong",{parentName:"li"},"append-only")))),(0,a.kt)("li",{parentName:"ul"},"\u985e\u578b\uff1a",(0,a.kt)("strong",{parentName:"li"},"default"),"\u3001",(0,a.kt)("strong",{parentName:"li"},"append-only"),"\u3001",(0,a.kt)("strong",{parentName:"li"},"ndjson"),"\u3001",(0,a.kt)("strong",{parentName:"li"},"silent"))),(0,a.kt)("p",null,"Allows you to choose the reporter that will log debug info to the terminal about the installation progress."),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("strong",{parentName:"li"},"silent")," - \u4e0d\u8f38\u51fa\u7d00\u9304\u81f3\u4e3b\u63a7\u53f0\uff0c\u5373\u4f7f\u56b4\u91cd\u932f\u8aa4\u4e5f\u4e00\u6a23"),(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("strong",{parentName:"li"},"default")," - \u7576 stdout \u70ba TTY \u6642\u7684\u9810\u8a2d reporter"),(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("strong",{parentName:"li"},"append-only")," - \u7e3d\u662f\u5c07\u8f38\u51fa\u7d50\u679c\u9644\u52a0\u5728\u5c3e\u7aef\u3002 \u4e0d\u6703\u9032\u884c\u6e38\u6a19\u64cd\u4f5c"),(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("strong",{parentName:"li"},"ndjson")," -- \u6700\u8a73\u76e1\u7684 reporter \u4ee5 ",(0,a.kt)("a",{parentName:"li",href:"http://ndjson.org/"},"ndjson")," \u683c\u5f0f\u5370\u51fa\u6240\u6709\u65e5\u8a8c")),(0,a.kt)("p",null,"If you want to change what type of information is printed, use the ",(0,a.kt)("a",{parentName:"p",href:"/zh-TW/npmrc#loglevel"},"loglevel")," setting."),(0,a.kt)("h3",{id:"--use-store-server"},"--use-store-server"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"\u9810\u8a2d\u503c\uff1a",(0,a.kt)("strong",{parentName:"li"},"false")),(0,a.kt)("li",{parentName:"ul"},"\u985e\u578b\uff1a",(0,a.kt)("strong",{parentName:"li"},"Boolean"))),(0,a.kt)("p",null,"Starts a store server in the background. The store server will keep running after installation is done. To stop the store server, run ",(0,a.kt)("inlineCode",{parentName:"p"},"pnpm server stop")),(0,a.kt)("h3",{id:"--shamefully-hoist"},"--shamefully-hoist"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"\u9810\u8a2d\u503c\uff1a",(0,a.kt)("strong",{parentName:"li"},"false")),(0,a.kt)("li",{parentName:"ul"},"\u985e\u578b\uff1a",(0,a.kt)("strong",{parentName:"li"},"Boolean"))),(0,a.kt)("p",null,"Creates a flat ",(0,a.kt)("inlineCode",{parentName:"p"},"node_modules")," structure, similar to that of ",(0,a.kt)("inlineCode",{parentName:"p"},"npm")," or ",(0,a.kt)("inlineCode",{parentName:"p"},"yarn"),". ",(0,a.kt)("strong",{parentName:"p"},"WARNING"),": This is highly discouraged."),(0,a.kt)("h3",{id:"--ignore-scripts"},"--ignore-scripts"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"\u9810\u8a2d\u503c\uff1a",(0,a.kt)("strong",{parentName:"li"},"false")),(0,a.kt)("li",{parentName:"ul"},"\u985e\u578b\uff1a",(0,a.kt)("strong",{parentName:"li"},"Boolean"))),(0,a.kt)("p",null,"Do not execute any scripts defined in the project ",(0,a.kt)("inlineCode",{parentName:"p"},"package.json")," and its dependencies."),(0,a.kt)("h3",{id:"--filter-package_selector"},"--filter ","<","package_selector>"),(0,a.kt)("p",null,(0,a.kt)("a",{parentName:"p",href:"/zh-TW/filtering"},"Read more about filtering.")),(0,a.kt)("h3",{id:"--resolution-only"},"--resolution-only"),(0,a.kt)("p",null,"Added in: v8.3.0"),(0,a.kt)("p",null,"Re-runs resolution: useful for printing out peer dependency issues."))}c.isMDXComponent=!0},1624:(e,t,n)=>{n.d(t,{Z:()=>l});const l=n.p+"assets/images/pnpm-install-922fbb8bb4d96b8f602a40e6cd07ee13.svg"}}]);