简体   繁体   English

为什么 create-react-app 会给出“package.json 中缺少依赖项”消息?

[英]Why does create-react-app give "Missing dependencies in package.json" message?

What's the problem:有什么问题:

I recently started learning reactjs.我最近开始学习 reactjs。 while creating a new react app, the build fails and only a package.json file is created.在创建新的反应应用程序时,构建失败并且只创建了 package.json 文件。

    > PS D:\react-projects> npx create-react-app app-name Creating a new
    > React app in D:\react-projects\exercount.
    > 
    > Installing packages. This might take a couple of minutes. Installing
    > react, react-dom, and react-scripts with cra-template...
    > 
    > 
    > added 1396 packages, and changed 1 package in 9m 203 packages are
    > looking for funding   run `npm fund` for details
    > Missing dependencies in package.json

What I used:我用了什么:

  • VS CODE 1.69 VS 代码 1.69
  • Windows 10 Home single language Version 10.0.19044 Build 19044 Windows 10 家庭单语言版本 10.0.19044 Build 19044
  • Node v16.16节点 v16.16
  • NPM v8.13.2 NPM v8.13.2

when did i encounter it: I tried to create my first react app by following the reactjs official tutorial.我什么时候遇到它:我尝试按照 reactjs 官方教程创建我的第一个反应应用程序。 I opened vs code in administrator mode and ran the following command in the terminal我以管理员模式打开 vs code 并在终端中运行以下命令

npx create-react-app myapp

while this worked fine in my friends linux laptop, it failed in my windows one.虽然这在我的朋友 linux 笔记本电脑上运行良好,但在我的 windows 笔记本电脑上却失败了。 All it does is throw a "Missing dependancies in package.json" message and only builds a folder with one package.json file.它所做的只是抛出一个“package.json 中缺少依赖项”消息,并且只构建一个包含一个 package.json 文件的文件夹。

What have i tried:我试过什么:

  • various commands to create the app like - npx, npm create-react-app and create-react-app itself创建应用程序的各种命令,例如 - npx、npm create-react-app 和 create-react-app 本身
  • have run those commands with and without the "-use--npm" flag运行了带有和不带有“-use--npm”标志的这些命令
  • forced flushed the npm cache强制刷新 npm 缓存
  • uninstalled and reinstalled vs code, npm and node卸载并重新安装vs代码,npm和节点

All i found online were a few similar questions with only small number of them with answers.我在网上找到的只是一些类似的问题,只有少数有答案。 I have tried all of them and nothing worked.If you know what could be causing this, it would be helpful.我已经尝试了所有这些,但没有任何效果。如果您知道可能导致这种情况的原因,那将会很有帮助。

Screenshots:截图:

terminal终端

package.json file package.json文件

I had the same.我有同样的。 The problem was resolved by downgrading npm to version 8.3.0 npm install -g npm@8.3.0问题已通过将 npm 降级到版本 8.3.0 npm install -g npm@8.3.0

Were you able to find an answer to this problem?你能找到这个问题的答案吗? I'm having exactly the same result.我得到完全相同的结果。 Thanks!谢谢! Sherry雪莉酒

暂无
暂无

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

相关问题 npx create-react-app myApp 不工作 _npx\10796" 因为它不包含 package.json 文件 - npx create-react-app myApp does not work _npx\10796" as it does not contain a package.json file create-react-app 只创建 package.json 文件 - create-react-app only creates package.json file create-react-app 的 package.json 中的“代理”字段如何工作? - How does the “proxy” field in a create-react-app's package.json work? 从 React Redux 中的 package.json 获取版本号(create-react-app) - Get version number from package.json in React Redux (create-react-app) 为什么在使用“npx create-react-app”命令创建项目时,除了“node_modules”和“package.json”之外没有任何文件和文件夹? - Why there isn't any file and folder except 'node_modules' and 'package.json' anymore when creating a project with 'npx create-react-app' command? npx create-react-app myapp 错误“\AppData\Roaming\npm-cache\_npx\19748”在 appdata 文件夹中不包含 package.json 文件 - npx create-react-app myapp error "\AppData\Roaming\npm-cache\_npx\19748" does not contain a package.json file in appdata folder 为什么 npx create-react-app 给出代码 127 错误? - Why does npx create-react-app give a code 127 error? npm 不安装 package.json 依赖项 - npm does not install the package.json dependencies 在Windows上,package.json中的React Create App Proxy Agent在Windows上运行缓慢 - React create app proxy agent in package.json is slow on Windows package.json 中的“依赖项”中可能缺少模块 - A module may be missing from 'dependencies' in package.json
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM