简体   繁体   English

Windows 10 和 Linux 的 Windows 子系统上的 NodeJS

[英]NodeJS on Windows 10 and Windows Subsystem for Linux

I'm trying to get Expo, a platform for making native mobile apps, to run on a Windows 10 machine.我正在尝试让 Expo(一个用于制作原生移动应用程序的平台)在 Windows 10 机器上运行。 A preprequisite for Expo is NodeJS so I installed that. Expo 的先决条件是 NodeJS,所以我安装了它。 However, I ran into some issues getting Expo to work using Git Bash and so now I'm trying to get Windows Subsystem for Linux (WSL) operational to use that instead. However, I ran into some issues getting Expo to work using Git Bash and so now I'm trying to get Windows Subsystem for Linux (WSL) operational to use that instead. Ubuntu 18.04 LTS has been downloaded and initialized. Ubuntu 18.04 LTS 已下载并初始化。 Using a CMD here is what's happening:使用 CMD 会发生以下情况:

C:\Users\jason.black>node -v
v12.13.0

C:\Users\jason.black>wsl
jason@PC1:/mnt/c/Users/jason.black$ node -v

Command 'node' not found, but can be installed with:
sudo apt install nodejs

jason@PC1:/mnt/c/Users/jason.black$ sudo apt install nodejs
[sudo] password for jason:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package nodejs
jason@PC1:/mnt/c/Users/jason.black$

So it appears that NodeJS which was initially installed is not available to WSL.因此,最初安装的 NodeJS 似乎对 WSL 不可用。 Does that seem right?这看起来对吗? And why won't it install so WSL can access it?为什么不安装它以便 WSL 可以访问它?

If you're trying to access Node installed on the windows site, you may specify the PATH to /mnt/x/.../path/to/node/bin;如果您尝试访问安装在 windows 站点上的 Node,您可以将 PATH 指定为 /mnt/x/.../path/to/node/bin; if you're trying to install nodejs on the Linux side, may be you're looking for the package 'node' (not nodejs), or you can just download the portable version:https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz if you're trying to install nodejs on the Linux side, may be you're looking for the package 'node' (not nodejs), or you can just download the portable version:https://nodejs.org/dist/v12 .13.1/node-v12.13.1-linux-x64.tar.xz

For someone who's not familiar to Linux:对于不熟悉 Linux 的人:

# will be download to home directory
cd ~
# using wget
wget https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz
# using curl
curl -o node-v12.13.1-linux-x64.tar.xz https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz
# extract
tar xf node-v12.13.1-linux-x64.tar.xz

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM