天天看點

node.js 和 yarn 的置換

一、介紹:

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.。

二、版本選擇:

去下載下傳位址https://nodejs.org/en/download/,選擇自己對應的系統進行下載下傳。

此處規定使用版本為最新版本。

選擇對應的Installer下載下傳安裝包。

三、Node.js安裝(windows):

執行.msi檔案。

在安裝過程中的配置界面,請勾選Node.js runtime、npm package manager和Add to PATH這三個選項,一直到安裝完成。

點選“開始”菜單按鈕,輸入PowerShell,找到Windows PowerShell,用管理者身份打開之後輸入指令node -v和npm -v,能夠分别檢視Node.js和npm的版本資訊,表示安裝完成。

# 安裝yarn

npm install -g yarn --verbose

# 更改政策

set-ExecutionPolicy RemoteSigned

選擇Y

四、yarn換源:

在目錄C:\Users\zwx中,建立或編輯.yarnrc,在最後加上内容:

如果無法建立,可以下載下傳

node.js 和 yarn 的置換

添加文本内容:

registry "https://registry.npm.taobao.org" ELECTRON_MIRROR "https://cdn.npm.taobao.org/dist/electron/"

五、npm對比yarn指令:

npm install === yarn npm install xxx --save === yarn add xxx npm uninstall xxx --save === yarn remove xxx npm install xxx --save-dev === yarn add xxx --dev npm update --save === yarn upgrade npm install xxx@latest --save === yarn add xxx npm install xxx --global === yarn global add xxx npm init === yarn init npm init --yes/-y === yarn init --yes/-y npm link === yarn link npm outdated === yarn outdated npm publish === yarn publish npm run === yarn run npm cache clean === yarn cache clean npm login === yarn login npm test === yarn test

六、釋出後重新整理包:

官網:https://npmmirror.com/

在輸入框裡搜尋子產品名稱,點選SYNC按鈕。

繼續閱讀