ReactJS npm start 编译失败
Posted
技术标签:
【中文标题】ReactJS npm start 编译失败【英文标题】:ReactJS npm start Failed to compile 【发布时间】:2018-11-30 19:35:12 【问题描述】:npm start
react@16.4.1
react-dom@16.4.1
反应三渲染器
App.js
import React3 from 'react-three-renderer';
import * as THREE from 'three';
import React from "react";
import ReactDOM from 'react-dom';
警告
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-three@0.9.7 requires a peer of react@^15.4.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-three@0.9.7 requires a peer of react-dom@^15.4.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-three@0.9.7 requires a peer of three@^0.83.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-three-renderer@3.2.4 requires a peer of react@~15.6.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-three-renderer@3.2.4 requires a peer of react-dom@~15.6.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-three-renderer@3.2.4 requires a peer of three@~0.86.0 but none is installed. You must install peer dependencies yourself.
节点脚本/start.js
正在启动开发服务器...
编译失败。
./node_modules/react-three-renderer/lib/React3CompositeComponentWrapper.js
Module not found: Can't resolve 'react-dom/lib/ReactCompositeComponent' in '/Users/ernekyan/react-app/project/node_modules/react-three-renderer/lib'
有人可以给我建议吗?
【问题讨论】:
你使用的是哪个节点版本? @HridayModi v8.11.3 【参考方案1】:您可以再次尝试npm install
以查看是否已安装所有软件包。
否则你可以通过运行npm install <package> -D
(自动保存到 package.json)来查看自己添加包
或者在此处查看提供的解决方案:npm WARN ... requires a peer of ... but none is installed. You must install peer dependencies yourself 因为自动安装 peerDependencies 已从 npm v3+ 中删除。
更多信息:https://github.com/npm/npm/releases/tag/v3.0.0
#6930 (#6565) peerDependencies 不再导致任何东西被隐式安装。相反,如果缺少包 peerDependencies,npm 现在会发出警告,但由模块的使用者(即您)确保对等点被安装/包含在 package.json 中作为包的直接依赖项或 devDependencies。 em>
【讨论】:
另请提供其他解决方案(链接)。正如您在 NPM 更改日志中看到的那样,您现在可以控制安装 peerDependencies。例如,您需要将 add ajv@^6.0.0 安装到您的 package.json(或调用 npm install ajv@6.0.0)。三个 (three@~0.86.0)、react (react@~15.6.1) 和 react-dom (react-dom@~15.6.1) 也是如此。以上是关于ReactJS npm start 编译失败的主要内容,如果未能解决你的问题,请参考以下文章