如何解决 "prop-types not found on request" 错误?

How to resolves "prop-types not found on request" error?

我正在尝试使用 material-ui Next and fuse-box 开始一个新的 ReactJS 项目。

我已经安装了所有依赖项:

"dependencies": {
    "material-ui": "^1.0.0-beta.27",
    "material-ui-icons": "^1.0.0-beta.17",
    "prop-types": "^15.6.0",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "reflect-metadata": "^0.1.8"
 }

但我一直看到错误:"prop-types not found on request"。断点在这里:

var _propTypes = require('prop-types');

exports['default'] = {
  jss: (0, _propTypes.shape)({...

知道是什么导致了这个错误吗?


我的代码

我的应用页面模仿this example provided by Material UI:

import * as React from "react";
import { PropTypes } from 'prop-types'; 
import { Component } from "react";
import { render } from 'react-dom';
import { Button } from 'material-ui/Button';
import './App.css';

class App extends Component {

    constructor(props) {
        super(props);

        this.state = {
            isAuthenticated: true
        };
    }

    render() {
        const { classes } = this.props;
        const { isAuthenticated } = this.state;
        return (
            <Button raised color="primary">
              Hello World
            </Button>
        );
    }
}

App.propTypes = {
  classes: PropTypes.object.isRequired
};

export default App;

此应用程序组件在我的索引文件中呈现如下:

ReactDOM.render(<App />, document.getElementById('root'));

我从 fusebox 的一位创造者那里得到了答案 here

我使用了错误的导入语句:

import { PropTypes } from 'prop-types'; 

使用保险丝盒的正确方法是:

import * as PropTypes from 'prop-types'