node 与 yarn 的使用。

yarn的安装与使用

在 Nodejs 环境下,通过npm install -g yarn 命令进行全局安装

1
2
3
4
5
6
yarn version
yarn init
yarn install
yarn add vue
yarn add vue-router
yarn remove vue-router

yarn 中文文档

windows 下安装 n 模块失败,直接下载最新版覆盖安装即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
C:\Windows\system32>npm install -g n
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\nodejs\\node.exe" "C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "n"
npm ERR! node v6.10.2
npm ERR! npm v3.10.10
npm ERR! code EBADPLATFORM

npm ERR! notsup Unsupported platform for n@2.1.8: wanted {"os":"!win32","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: !win32
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64

npm ERR! Please include the following file with any support request:
npm ERR! C:\Windows\system32\npm-debug.log

下载最新版

安装最新版之后,安装 n 模块,还是一样,因为不支持 64 位的操作系统。

1
2
3
4
5
6
7
8
9
10
C:\Users\andy>npm install -g n
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for n@2.1.8: wanted {"os":"!win32","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: !win32
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\andy\AppData\Roaming\npm-cache\_logs\2017-08-27T09_25_45_159Z-debug.log

cnpm

安装 cnpm -> 淘宝 NPM 镜像
淘宝 NPM 镜像

1
npm install -g cnpm --registry=https://registry.npmmirror.com

yarn

yarn 中文
比较简单的方式安装,不过,官方不推荐这种方式。

1
npm install -g yarn

建议通过推荐的方式安装,可下载 .msi 程序安装。
Download Installer

WebStorm 启动项设置影响运行的依赖版本

如下图:


当我打开一个 react 项目时,添加一个启动配置项,选 npm ,结果在启动的时候,显示相关依赖版本为很早以前的版本,原来 Package manager 一项默认选中的红框,但我实际的安装路径其实为练功框标记的下面那个,修改之后就好了。