PageSourceSearch

https://homyzone.pages.dev/assets/package-json-K8gr2Uy2.js

js homyzone.pages.dev collected 2026-10-03 05:14:34 UTC 2,952 bytes, 4 lines download raw bytes

1import{_ as c}from"./Blog.vue_vue_type_script_setup_true_lang-CILXmGNC.js";import{u as r,c as i,o as l,w as p,a as e,b as n}from"./app-CFzPwlWL.js";import"./Comments-DGuXOcGi.js";const _="package.json 字段含义记录",b="2022-01-11T10:49:53.000Z",j="",f="zh",w="1min",x=[{property:"og:title",content:"package.json 字段含义记录"},{name:"twitter:title",content:"package.json 字段含义记录"}],y={__name:"package-json",setup(d,{expose:o}){const t={title:"package.json 字段含义记录",date:"2022-01-11T10:49:53.000Z",hero_image:"",lang:"zh",duration:"1min",meta:[{property:"og:title",content:"package.json 字段含义记录"},{name:"twitter:title",content:"package.json 字段含义记录"}]};return o({frontmatter:t}),r({title:"package.json 字段含义记录",meta:[{property:"og:title",content:"package.json 字段含义记录"},{name:"twitter:title",content:"package.json 字段含义记录"}]}),(m,a)=>{const s=c;return l(),i(s,{frontmatter:t},{default:p(()=>a[0]||(a[0]=[e("div",{class:"prose"},[e("h3",{id:"为什么script里的命令不用加node-modules-bin前缀?",tabindex:"-1"},[n("为什么"),e("code",null,"script"),n("里的命令不用加"),e("code",null,"node_modules/.bin"),n("前缀? "),e("a",{class:"header-anchor",href:"#为什么script里的命令不用加node-modules-bin前缀?","aria-hidden":"true"},"#")]),e("p",null,[n("当你执行 "),e("code",null,"npm run"),n(" 命令的时候,会把"),e("code",null,"node_modules/.bin"),n("添加到环境变量中,所以只要你的项目或全局安装了指定依赖,你就可以放心的直接使用 而不用添加任何前缀。")]),e("h3",{id:"bin-字段是干啥的",tabindex:"-1"},[n("bin 字段是干啥的 "),e("a",{class:"header-anchor",href:"#bin-字段是干啥的","aria-hidden":"true"},"#")]),e("p",null,[n("简单来说,bin 是用来存放可执行文件的,里面是 command name 到本地可执行文件的映射, 可以有一至多个 比如你写了一个 cli, 要想可以被执行,你就需要在 package.json 里添加 bin 字段,指向你要执行的脚本 所以当依赖被安装的时候,它的 bin 指向的"),e("strong",null,"node可执行文件"),n(" 就会被软链过去 比如")]),e("div",{class:"code-block-with-copy"},[e("pre",{class:"language-json"},[e("code",{class:"language-json"},[e("span",{class:"token property"},'"bin"'),e("span",{class:"token operator"},":"),n(),e("span",{class:"token punctuation"},"{"),n(`
2    `),e("span",{class:"token property"},'"switch-helper"'),e("span",{class:"token operator"},":"),n(),e("span",{class:"token string"},'"index.js"'),n(`
3  `),e("span",{class:"token punctuation"},"}"),e("span",{class:"token punctuation"},","),n(`
4`)])])]),e("p",null,"当你安装switch-helper的时候,就会从对应的index.js 创建软链到 /usr/local/bin/switch-helper")],-1)])),_:1,__:[0]})}}};export{b as date,y as default,w as duration,j as hero_image,f as lang,x as meta,_ as title};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.