使用Bash on Ubuntu on Windows安装nodebrew和nodejs

由于相当落后时代,为了尽量赶上时代的脚步,我想在自己的设备上构建一个node.js开发环境,并尝试做一些事情…

顺带一提,为了在Visual Studio Code上进行调试,最终我还是在Windows上普通地安装了nodist和Node.js。现在已经不再需要Bash on Ubuntu on Windows或者nodebrew了。

安装和设置

在Windows上使用的Ubuntu子系统

听说Windows10可以使用Bash,所以我马上去试试。安装方法就先不提了。

设置日语字体

image

视觉工作室代码

因为个人觉得很好用,所以我会选择使用它。下载安装程序并进行安装。

Bash的设置

image
{
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\bash.exe"
}

使用nodebrew安装。

我们从这里开始使用Bash进行操作。您可以按照nodebrew存储库上的自述文件进行操作。

$ curl -L git.io/nodebrew | perl - setup
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0
100 24340  100 24340    0     0   5300      0  0:00:04  0:00:04 --:--:-- 1215k
Fetching nodebrew...
Installed nodebrew in $HOME/.nodebrew

========================================
Export a path to nodebrew:

export PATH=$HOME/.nodebrew/current/bin:$PATH
========================================
$ export PATH=$HOME/.nodebrew/current/bin:$PATH
$ source ~/.bashrc

只需给出一种选择:
最后运行 $ nodebrew help,只要有任何输出都可以。

安装 Node.js

如果能够到达这一步,就很简单了。刚刚安装的nodebrew将被用来安装node.js。

$ nodebrew install-binary stable
Fetching: https://nodejs.org/dist/v7.8.0/node-v7.8.0-linux-x64.tar.gz
######################################################################## 100.0%
Installed successfully
$ nodebrew use latest
use v7.8.0
$ node -v
v7.8.0

结束了。

你好,世界 (Nǐ ,

image

出现了错误。这是什么意思…?

我不太清楚,但似乎是从两天前开始出现的。
没办法,我们在Bash上执行$ node app.js吧。

$ node app.js
Server running at http://127.0.0.1:3000/

今天就到这里算了吧。
不太清楚为什么在VisualStudioCode上无法调试,先观察一下吧。

2017年4月9日增补

从一开始在bash中安装node,似乎在使用VSCode调试nodejs时不能使用该node。因此,我决定乖乖地安装Windows版本的nodist。

广告
将在 10 秒后关闭
bannerAds