Windows10搭建Node.js环境

准备系统的学习前端,试着把学习过程记录下来,下面是我搭建node.js环境的过程:

-使用git安装nvmw
1.打开git bash

$cd d:
$mkdir git
$cd git 
$git clone https://github.com/cnpm/nvmw.git

2.配置环境变量
这里写图片描述

3.打开命令行或者power shell

Windows PowerShell
版权所有 (C) 2016 Microsoft Corporation。保留所有权利。

PS C:\Users\Bingo> nvmw

Node Version Manager for Windows

Usage:
  nvmw help                          Show this message
  nvmw install [version] [arch]      Download and install a [version]
                                       for [arch] architecture (optional)
  nvmw uninstall [version]           Uninstall a [version]
  nvmw use [version]                 Modify PATH to use [version]
  nvmw ls                            List installed versions

Example:
  nvmw install v0.10.21        Install a specific version number of node.js
  nvmw use v0.10.21            Use the specific version
  nvmw install iojs            Install the latest version of io.js
  nvmw install iojs-v1.0.2     Install a specific version number of io.js
  nvmw use iojs-v1.0.2         Use the specific version io.js

  nvmw install v0.10.35 x86    Install a 32-bit version

-使用nvmw安装任意版本的node
关于nodejs版本https://nodejs.org/zh-cn/download/releases/

nvmw install 0.12.0

这个命令会报404文件下载不了

PS C:\Users\Bingo> nvmw install 0.12.0
Start installing node/v0.12.0 (x64) to D:\git\nvmw\v0.12.0
Download from http://npm.taobao.org/mirrors/node/v0.12.0/win-x64/node.exe, and save it as D:\git\nvmw\v0.12.0\node.exe
404 Not Found
Download D:\git\nvmw\v0.12.0\node.exe from http://npm.taobao.org/mirrors/node/v0.12.0/win-x64/node.exe failed

上面有个链接

http://npm.taobao.org/mirrors/node/v0.12.0/win-x64/node.exe

直接按照上面的链接下载不了,应该是路径有问题
又从网上查到了个和我不一样错误https://segmentfault.com/q/1010000004295724

C:\Users\Administrator>nvmw install 0.12.9
Start installing node/v0.12.9 (x64) to D:\Portable\nvmw\v0.12.9
Download from http://npm.taobao.org/mirrors/node/v0.12.9/x64/node.exe, and save
it as D:\Portable\nvmw\v0.12.9\node.exe
Done
Start install npm
Download file from https://raw.githubusercontent.com/joyent/node/v0.12.9/deps/np
m/package.json
package.json
node v0.12.9 does not include npm
http://npm.taobao.org/mirrors/node/v0.12.9/x64/node.exe

这个里面的链接 是可以在下载的,我把我的win-x64改成 x64也可以下载了
在安装的nvmw文件夹下的nvmw.bat 126行左右有代码修改如下:

if %NODE_TYPE% == iojs (
  set DIST_URL=%%
  if %ARCH% == x32 (
    set NODE_EXE_URL=%NVMW_IOJS_ORG_MIRROR%/%NODE_VERSION%/win-x86/iojs.exe
  ) else (
    set NODE_EXE_URL=%NVMW_IOJS_ORG_MIRROR%/%NODE_VERSION%/win-x64/iojs.exe
  )
) else (
  if %ARCH% == x32 (
    set NODE_EXE_URL=%NVMW_NODEJS_ORG_MIRROR%/%NODE_VERSION%/win-x86/node.exe
  ) else (
    set NODE_EXE_URL=%NVMW_NODEJS_ORG_MIRROR%/%NODE_VERSION%/win-x64/node.exe
  )
)

把上面的win-x64 改成 x64 就可以了

PS C:\Users\Bingo> nvmw install 0.12.0
Start installing node/v0.12.0 (x64) to D:\git\nvmw\v0.12.0
Download from http://npm.taobao.org/mirrors/node/v0.12.0/x64/node.exe, and save it as D:\git\nvmw\v0.12.0\node.exe
Done
Start install npm
Download file from https://raw.githubusercontent.com/nodejs/node/v0.12.0/deps/npm/package.json
package.json
Content length is 4.32kb
Download 100%, 4.32kb / 4.32kb, 143.91kb/s ...
Donwload done
Download file from http://npm.taobao.org/mirrors/npm/v2.5.1.zip
v2.5.1.zip
Redirect: http://cdn.npm.taobao.org/dist/npm/v2.5.1.zip
Download file from http://cdn.npm.taobao.org/dist/npm/v2.5.1.zip
v2.5.1.zip
Content length is 3.12mb
Download 100%, 3.12mb / 3.12mb, 3.22mb/s ...
Donwload done
Download npm 2.5.1 is done
Start unzip "D:\git\nvmw\v0.12.0\npm.zip" to "D:\git\nvmw\v0.12.0"
系统找不到指定的文件。
D:\git\nvmw\v0.12.0\npm-2.5.1
移动了         1 个目录。
已复制         1 个文件。
D:\git\nvmw\v0.12.0
npm install ok
Finished
Now using node v0.12.0 x64

经我测试下面这种版本号下载的时候需要修改链接http://npm.taobao.org/mirrors/node/v0.12.0/x64/node.exe

这里写图片描述

如果下载另一种版本的 就不用修改链接 直接用http://npm.taobao.org/mirrors/node/v7.7.3/win-x64/node.exe

这里写图片描述

我还不了解为什么会这样

最后配置环境变量path增加

D:\git\nvmw\v0.12.0

打开命令行或power shell

PS C:\Users\Bingo> npm

Usage: npm <command>

where <command> is one of:
    access, add-user, adduser, apihelp, author, bin, bugs, c,
    cache, completion, config, ddp, dedupe, deprecate, dist-tag,
    dist-tags, docs, edit, explore, faq, find, find-dupes, get,
    help, help-search, home, i, info, init, install, issues, la,
    link, list, ll, ln, login, ls, outdated, owner, pack,
    prefix, prune, publish, r, rb, rebuild, remove, repo,
    restart, rm, root, run-script, s, se, search, set, show,
    shrinkwrap, star, stars, start, stop, t, tag, test, tst, un,
    uninstall, unlink, unpublish, unstar, up, update, v,
    verison, version, view, whoami

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm faq          commonly asked questions
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    C:\Users\Bingo\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@2.5.1 D:\git\nvmw\v0.12.0\node_modules\npm

到此nodejs算是安装完了吧

参考:

https://fengmk2.com/blog/2014/03/node-env-and-faster-npm.html
https://segmentfault.com/q/1010000004295724
http://www.cnblogs.com/juedui0769/p/4920196.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值