Cannot find module @restart/context/forwardRef dur

2019-07-17 18:44发布

问题:

I recently started having a problem with npm build after upgrading to newer version of 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.

I tried running the provided yarn command but this is not a valid package name. Does anyone have an idea how to fix this without going back to the old version (which does not support tabs, which is something I am using)?

回答1:

This is an upstream issue with @restart/context, which just released a version that breaks importing forwardRef like this:

import forwardRef from '@restart/context/forwardRef'

Quick fix is to downgrade to 2.1.2 by running yarn add @restart/context@2.1.2.

Longer term fix is to wait for react-bootstrap to either fix their imports or lock their package.json to this version of @restart/context.

Edit: I added an issue to the react-bootstrap repo to track progress here: https://github.com/react-bootstrap/react-bootstrap/issues/3576