简体   繁体   English

无论我尝试什么都无法创建 package.json

[英]Cannot create package.json no matter what I try

I have a react project and I'm having problems with trying to create package.json file on the branch i'm on.我有一个反应项目,我在尝试在我所在的分支上创建package.json文件时遇到问题。 I have tried many of the top stack overflow answers in creating package.json but nothing seems to work.我在创建package.json尝试了许多顶级堆栈溢出答案,但似乎没有任何效果。 This project was working fine last night and package.json was there.这个项目昨晚运行良好, package.json就在那里。

When I run npm install I get the following errors.当我运行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.

I even tried running npm init -y to create a new package.json and I tried adding the configuration my self by pasting in the config from a package.json I have in a react project on another branch but I ran into a number of problems with that as well including having to remove or stash package.json and package-lock.json every time I want to switch branch or pull the latest from the branch which never happened before.我什至尝试运行npm init -y来创建一个新的package.json并且我尝试通过粘贴来自package.json的配置来添加我自己的配置我在另一个分支的反应项目中但是我遇到了许多问题这也包括每次我想切换分支或从以前从未发生过的分支中提取最新版本时,必须删除或package-lock.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

Any idea as to what is happening?知道发生了什么吗?

This is my file directory这是我的文件目录

File directory文件目录

When I do a git status, you can see my package-lock.json file is in my Untracked files.当我执行 git status 时,您可以看到我的package-lock.json文件在我的 Untracked 文件中。 I pushed this react project up to Github and I thought it might be that the README file and package.json files might have been added to gitignore but it doesn't seem to be the case.我将这个 react 项目推送到 Github,我认为可能是README文件和package.json文件可能已添加到gitignore但似乎并非如此。

If your local project is a copy of remote.如果您的本地项目是远程的副本。 Try this:尝试这个:

  1. Delete local project删除本地项目
  2. git clone <your repo name>
  3. enter to cloned folder and npm init进入克隆文件夹和npm init

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

相关问题 已解决无论我如何尝试都无法使CORS正常工作 - SOLVED Cannot get CORS to work no matter what I try 当我尝试 npm 安装或 npm 安装时<any-package> ,我看到“无法读取 null 的属性(读取‘edgesOut’)”并且 İ 有 package.json</any-package> - When i try to npm install or npm install <any-package>, i see "Cannot read properties of null (reading 'edgesOut')" and İ have package.json 我应该在 package.json 中为“类型”字段使用哪些值? - What values should I use in package.json for the 'types' field? 如何创建 package.json 文件? - How do I create a package.json file? 我对 package.json 中的脚本使用什么命名约定? - What naming convention do I use for scripts in package.json? NodeJS:当我尝试使用 package.json 的脚本执行命令时出错 - NodeJS: Error when I try to execute a command with the scripts of the package.json Docker找不到package.json - Docker cannot find package.json 当我尝试从 package.json 安装包时 NPM 崩溃 - NPM crashes when I try to install packages from package.json 当我尝试直接在package.json文件中执行脚本时,nodejs __dirname是一个点 - nodejs __dirname is a dot when I try to execute a script directly in package.json file 错误:找不到模块“../../package.json” - Error: Cannot find module '../../package.json'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM