npm学习(十七)之node_modules中的bin文件夹
可執(zhí)行文件
在本地模式下,可執(zhí)行文件指向的位置;
-
./node_modules/.bin?以便可以通過 npm 運(yùn)行的腳本使用它們。
-
例如,當(dāng)您運(yùn)行測(cè)試,將在路徑中?npm test。
-
npm為script字段中的腳本路徑都加上了node_moudles/.bin前綴
npm為script字段中的腳本路徑都加上了node_moudles/.bin前綴,這意味著:你在試圖運(yùn)行本地安裝的依賴在 node_modules/.bin 中的腳本的時(shí)候,可以省略node_modules/.bin這個(gè)前綴。例如:
我剛npm install webpack了,而在我的項(xiàng)目下的node_modules目錄的.bin子目錄下:
就多了一個(gè)叫做webpack的腳本
本來運(yùn)行這個(gè)腳本的命令應(yīng)該是:node_modules/.bin webpack
但由于npm已經(jīng)自動(dòng)幫我們加了node_modules/.bin前綴了,所以我們可以直接寫成:
"scripts": {"start": "webpack"}而不用寫成:
"scripts": {"start": "node_modules/.bin webpack"}原文:npm run adds node_modules/.bin to the PATH provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin prefix
總結(jié)
在本地環(huán)境下,可行性文件放在node_modules下的.bin文件夾中,npm為scripts字段中的腳本路徑自動(dòng)添加了node_modules/.bin前綴,所以可以直接寫
"scripts": {"start": "webpack"}
而不是
"scripts": {"start": "node_modules/.bin webpack"}
總結(jié)
以上是生活随笔為你收集整理的npm学习(十七)之node_modules中的bin文件夹的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深度学习基础思维导图
- 下一篇: 苹果无线耳机使用方法_苹果神器网球htt