【问题标题】:How do I get my node.js to work with my visual studio code?如何让我的 node.js 与我的 Visual Studio 代码一起工作?
【发布时间】:2021-07-29 06:20:45
【问题描述】:

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

npm:术语“npm”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,或者路径是否 包括,验证路径是否正确,然后重试。 在 line:1 char:1

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

【问题讨论】:

    标签: node.js reactjs visual-studio-code error-handling


    【解决方案1】:

    我不知道你这里有什么操作系统,我假设你有 Windows 10。

    我们一步一步来

    首先你必须安装 npm 依赖管理器附带的Nodejs。 安装后检查终端中的这些命令是否会返回一些内容:

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

    如果您没有重启计算机,请确保:

    你有一个 nodejs 文件夹在

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

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

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

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

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

    npm -v
    node -v
    # get the versions.
    

    现在你有 2 种可能性来创建 react-app

    您可以通过以下方式将其安装在本地计算机上

    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
    

    希望对你有所帮助

    【讨论】:

    • 谢谢,但还是不行。我刚刚遇到了同样的错误,但使用的是 npx 而不是 npm。
    • 你的操作系统是什么?窗户?
    猜你喜欢
    • 1970-01-01
    • 2013-08-07
    • 1970-01-01
    • 1970-01-01
    • 2013-12-08
    • 1970-01-01
    • 2023-02-02
    • 1970-01-01
    • 2011-12-01
    相关资源
    最近更新 更多