如何让我的 node.js 与我的 Visual Studio 代码一起工作? [英] How do I get my node.js to work with my visual studio code?

查看:30
本文介绍了如何让我的 node.js 与我的 Visual Studio 代码一起工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让我的 node.js 与我的 Visual Studio 代码终端一起工作.我确实安装了 node.js,但我无法创建 React 应用程序.不知道怎么回事,求帮助.我在 Visual Studio 代码终端上输入npm create-react-app ecommerce-app"并得到以下错误:

I can't get my node.js to work with my visual studio code terminal. I do have node.js installed but I can't create a react app. I don't know what is wrong, please help. I type in on the Visual Studio code terminal "npm create-react-app ecommerce-app" and get the following error:

npm :术语npm"不被识别为 cmdlet、函数、脚本文件或可运行程序的名称.检查名称的拼写,或者路径是否为包括在内,请验证路径是否正确,然后重试.在行:1 字符:1

npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

  • npm create-react-app ecommerce-app
  + CategoryInfo          : ObjectNotFound: (npx:String) [], CommandNotFoundException
  + FullyQualifiedErrorId : CommandNotFoundException

推荐答案

我不知道您使用的是什么操作系统,我假设您使用的是 Windows 10.

首先,您必须安装 Nodejs,它与 npm 依赖项管理器一起提供.安装后,检查终端中的这些命令是否会返回一些内容:

First you have to install Nodejs which comes with the npm dependency manager. Once installed check that these commands in a terminal return you something:

npm -v
# returns the version of npm installed
node -v
# sends you the version of nodejs installed

如果您没有任何东西重新启动计算机,请确保:

你有一个 nodejs 文件夹

You have a nodejs folder in

C:\Program Files\nodejs #(for the 64bits version)
C:\Program Files (x86)\nodejs #(for the 32bits version)

然后检查你是否有你的 Path 变量 nodejs

转到系统属性,然后是环境变量并在用户变量部分添加:

Go to System Properties, then Environment variables and add in the section User variable:

# New -> 
variable name: Node 
value of the variable: C:\Program Files\nodejs #(for the 64bits version)
# is the path to your nodejs folder

完成后,您应该输入前面的命令:

Once this is done you should by typing the previous commands:

npm -v
node -v
# get the versions.

现在你有 2 种可能来创建反应应用

或者您通过执行以下操作将其安装在本地计算机上

npm i -g create-react-app
# this command will install (i) the creat-react-app package in global (-g) on your machine 
# and you can create a project with the command
reate-react-app ecommerce-app

或者您可以使用允许您不在本地安装软件包的 npx 命令:

npx create-react-app ecommerce-app

希望对你有所帮助

这篇关于如何让我的 node.js 与我的 Visual Studio 代码一起工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆