【问题标题】:Unable to install npx create-react-app@3.3.0 nucampsite无法安装 npx create-react-app@3.3.0 nucampsite
【发布时间】:2020-10-22 01:20:54
【问题描述】:

按照我学校的指示,我尝试安装“npx create-react-app@3.3.0 nucampsite”,但它打开了带有文件 npm-cli.js 的 Visual Studio 代码

我尝试从 Visual Studio Code 运行命令,但收到以下错误消息:

C:\Users\Jay\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:1
npm/usr/bin/nodejs
^

ReferenceError: npm is not defined
   at Object.<anonymous> (C:\Users\Jay\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:1:1)
   at Module._compile (internal/modules/cjs/loader.js:1138:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
   at Module.load (internal/modules/cjs/loader.js:986:32)
   at Function.Module._load (internal/modules/cjs/loader.js:879:14)
   at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
   at internal/main/run_main_module.js:17:47

在 Visual Studio Code 的第 1 行,这是我所拥有的:

npm/usr/bin/nodejs 

【问题讨论】:

  • 该命令的结果是什么:node -v &amp;&amp; npm -v &amp;&amp; npx -v?
  • 所以当我运行 node -v 时,它显示的是 v12.18.2。当我运行 npm -v 和 npx-v C:\Users\Amraze Pirani\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:1 npm/usr/bin/nodejs ^ ReferenceError: npm is未在对象中定义。我觉得它与 npm-cli.js 文件有关,因为我编辑了该文件的第一行
  • 基本上它显示的错误信息和我上面的一样
  • 看起来你是如何设法安装 node 但不是 npmnpx。请尝试重新安装node。安装后你应该有nodenpmnpx。 PS:请使用“`”在cmets中突出显示您消息的代码部分:)

标签: node.js reactjs npm create-react-app npm-cli


【解决方案1】:

已修复!我卸载了 node 和 npm,然后重新安装了它,它似乎工作得很好!谢谢你们!

【讨论】:

    【解决方案2】:

    您编写的代码是正确的,但是 - 在您的 VS Code 终端中运行它:

    npm --version
    

    如果它没有为您提供 npm 版本,则意味着您没有安装它,这很可能是问题所在。

    查看this页面进行安装。

    【讨论】:

      猜你喜欢
      • 2019-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-11
      • 2021-09-07
      • 2023-02-05
      • 1970-01-01
      相关资源
      最近更新 更多