在 npm 构建期间找不到module @restart/context/forwardRef

IT技术 javascript reactjs npm npm-install react-bootstrap
2021-05-17 04:38:08

我最近npm build在升级到react-bootstrap( 1.0.0-beta.6) 的较新版本后开始遇到问题

Creating an optimized production build...
Failed to compile.

Cannot find module: '@restart/context/forwardRef'. Make sure this package is installed.
./node_modules/react-bootstrap/es/ThemeProvider.js

You can install this package by running: yarn add @restart/context/forwardRef.

我尝试运行提供的yarn命令,但这不是有效的包名称。有没有人知道如何在不回到旧版本的情况下解决这个问题(它不支持标签,这是我正在使用的东西)?

1个回答

这是@restart/context的上游问题,它刚刚发布了一个forwardRef像这样中断导入的版本

import forwardRef from '@restart/context/forwardRef'

快速修复是通过运行降级到 2.1.2 yarn add @restart/context@2.1.2

长期修复是等待react-bootstrap修复它们的导入或将它们锁定package.json到此版本的@restart/context.

编辑:我在react-bootstraprepo 中添加了一个问题以在此处跟踪进度:https : //github.com/react-bootstrap/react-bootstrap/issues/3576