【问题标题】:Cannot create package.json no matter what I try无论我尝试什么都无法创建 package.json
【发布时间】:2020-01-04 07:17:23
【问题描述】:

我有一个 react 项目,但在尝试在我所在的分支上创建 package.json 文件时遇到问题。我在创建package.json 时尝试了许多顶级堆栈溢出答案,但似乎没有任何效果。这个项目昨晚运行良好,package.json 在那里。

当我运行npm install 时,出现以下错误。

 npm install
 npm WARN saveError ENOENT: no such file or directory, open 
 '/Users/wmannix/dev_repos/optic_link/integrator-ui/package.json'
 npm WARN enoent ENOENT: no such file or directory, open 
 '/Users/wmannix/dev_repos/optic_link/integrator-ui/package.json'
 npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0- 
 dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 
 3.7.0-beta but none is installed. You must install peer dependencies yourself.
 npm WARN integrator-ui No description
 npm WARN integrator-ui No repository field.
 npm WARN integrator-ui No README data
 npm WARN integrator-ui No license field.

我什至尝试运行npm init -y 来创建一个新的package.json,并尝试通过从package.json 粘贴配置来添加我自己的配置我在另一个分支的反应项目中但我遇到了一个数字与此相关的问题也包括每次我想切换分支或从分支中提取以前从未发生过的最新内容时都必须删除或隐藏package.jsonpackage-lock.json

git pull
Updating 73f82bc34..185bce04c
error: The following untracked working tree files would be overwritten by merge:
integrator-ui/package-lock.json
Please move or remove them before you merge.
Aborting

知道发生了什么吗?

这是我的文件目录

File directory

当我执行 git status 时,您可以看到我的 package-lock.json 文件在我的未跟踪文件中。我将这个 react 项目推到了 Github 上,我认为可能是 README 文件和 package.json 文件可能已添加到 gitignore 但似乎并非如此。

【问题讨论】:

    标签: node.js reactjs git npm


    【解决方案1】:

    如果您的本地项目是远程的副本。试试这个:

    1. 删除本地项目
    2. git clone <your repo name>
    3. 进入克隆文件夹和npm init

    【讨论】:

      猜你喜欢
      • 2019-06-20
      • 1970-01-01
      • 2020-10-31
      • 1970-01-01
      • 2020-10-01
      • 1970-01-01
      • 2011-06-30
      • 2017-10-27
      • 2020-08-11
      相关资源
      最近更新 更多