簡體   English   中英

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

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

我正在嘗試讓 Expo(一個用於制作原生移動應用程序的平台)在 Windows 10 機器上運行。 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. Ubuntu 18.04 LTS 已下載並初始化。 使用 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$

因此,最初安裝的 NodeJS 似乎對 WSL 不可用。 這看起來對嗎? 為什么不安裝它以便 WSL 可以訪問它?

如果您嘗試訪問安裝在 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

對於不熟悉 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