本文介绍了正在安装Reaction路由器,但不更新Package.json文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装react-router-dom,在显示许多警告消息后,它不会更新package.json文件。Package.json侧依赖项对象块中的文件未显示reac-router-dom版本信息。

反应路由器:

npm i react-router-dom
npm WARN saveError ENOENT: no such file or directory, open 'D:LinuxIDEAll-WorkspaceJavaScript-Workspacepackage.json'
npm WARN enoent ENOENT: no such file or directory, open 'D:LinuxIDEAll-WorkspaceJavaScript-Workspacepackage.json'
npm WARN @webpack-contrib/[email protected] requires a peer of webpack@^4.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN @webpack-contrib/[email protected] requires a peer of webpack@^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@>=15 but none is installed. You must install peer dependencies yourself.
tpm WARN [email protected] requires a peer of webpack@^2.0.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer depealled. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^2.0.0 installed. You must install peer dependencies yourself.
|pm WARN [email protected] requires a peer of webpack@^4.4.0 but none is installed. You must install peer dependencies yourself.| ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependenc installed. You must install peer dependencies yourself.
ipm WARN JavaScript-Workspace No description
es yourself.
npm WARN [email protected] requires a peer of webpack@^4.x.x but none is
ipm WARN JavaScript-Workspace No license field.
nstalled. You must install peer dependencies yourself.                   lesfsevents):
npm WARN [email protected] requires a peer of webpack@^4.4.0 but [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"wiis installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@>=15 but none isnpm WARN [email protected] requires a peer of webpack@^4.4.0 but none
 is installed. You must install pe
er dependencies yourself.
npm WARN [email protected] requires a peer of react@>=15 but none is
 installed. You must install peer
dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^4.4.0 but none dep: is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@>=15 but none is installed. You must install peer dependencies yourself.
npm WARN JavaScript-Workspace No descriptionnpm WARN JavaScript-Workspace No repository field.
npm WARN JavaScript-Workspace No README data
npm WARN JavaScript-Workspace No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ [email protected] 1 package and audited 11195 packages in 13.378sfound 0 vulnerabilities

Package.json

{
  "name": "lyricfinder_react",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "react-scripts": "1.1.5"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

npm

您需要将--save-S作为选项放入推荐答案安装,如下所示:npm install -S react-router-dom。然后告诉NPM将其添加到Package.json中。或者,如果要将其另存为开发人员依赖项,则添加-D

编辑

根据这个答案:https://stackoverflow.com/a/44441625/5997891,以及下面的注释,从npm版本5开始,npm install命令默认保存包。

这篇关于正在安装Reaction路由器,但不更新Package.json文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 15:11