我正在处理一个react项目,在实现这个包https://www.npmjs.com/package/react-bootstrap-typeahead之后,我得到了下面的错误,然后我得到下面的错误。
Failed to compile
./node_modules/react-popper/lib/cjs/Popper.js
Module not found: Can't resolve '@babel/runtime/helpers/objectWithoutPropertiesLoose' in 'E:\reactjs\deveans-react-version\node_modules\react-popper\lib\cjs'
This error occurred during the build time and cannot be dismissed.我找到了许多解决方案,我也尝试过https://github.com/jquense/yup/issues/216,但是仍然会出现相同的错误。
但是,当我移除“提前输入”组件时,它就可以正常工作了。
import React , { Component } from 'react'
import {Typeahead} from 'react-bootstrap-typeahead';
import 'react-bootstrap-typeahead/css/Typeahead.css';
class States extends Component {
state = {
multiple: false,
options: [
{id: 1, label: 'Pakistan'},
{id: 2, label: 'Indonesia'},
{id: 3, label: 'Turkey'},
{id: 4, label: 'Brazil'},
]
};
render () {
const {multiple} = this.state;
return (
<div>
<Typeahead
labelKey="label"
multiple={multiple}
options={this.state.options}
placeholder="Choose a state..."
/>
</div>
)
}
}
export default States发布于 2019-09-04 12:12:44
我找到了一个解决办法
npm install --save-exact @babel/runtime@7.0.0-beta.55然后删除package-json.lock文件和node_modules文件夹,然后用npm install重新安装。
对我来说很管用。
发布于 2021-02-18 17:17:04
您可以安装@babel/runtime来解决这个问题:
利用国家预防机制:
npm install --save @babel/runtime
使用纱线:
yarn add @babel/runtime
发布于 2021-03-24 15:29:22
确保将@babel/runtime安装到常规dependencies中,而不是devDependencies中(安装时不要使用--dev或-D标志)。
npm i @babel/runtime或
yarn add @babel/runtime否则,在进行生产安装时,它将丢失( devDependencies部分除外),这就是我所遇到的情况。
在大多数情况下,所有提供的答案都是正确的,但我想添加一个解释:Babel的运行时是随代码一起发布的生产运行库。,所以不能因为它在客户机上运行而忽略它。
https://stackoverflow.com/questions/57737270
复制相似问题