when is start npm I get TypeError: Cannot read property 'string' of undefined

时间:2017-12-18 08:34:30

标签: node.js reactjs

I have installed node js and mongo db then after that I started the node js. when I start the node js I get this error. This error is throwing from server.js file. But I couldn't check exactly which line is throwing error.

urlToImage

My server.js file has the following code at line 22403

/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:22404
  href: _react2['default'].PropTypes.string,
                                    ^

TypeError: Cannot read property 'string' of undefined
at Object.defineProperty.value (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:22404:38)
at __webpack_require__ (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:30:30)
at Object.<anonymous> (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:20101:20)
at __webpack_require__ (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:30:30)
at Object.i (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:19923:15)
at __webpack_require__ (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:30:30)
at Object.defineProperty.value (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:19790:20)
at __webpack_require__ (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:30:30)
at Object.defineProperty.value (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:19000:34)
at __webpack_require__ (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:30:30)
at Object.<anonymous> (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:320:22)
at __webpack_require__ (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:30:30)
at Object.<anonymous> (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:76:16)
at __webpack_require__ (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:30:30)
at Object.obj.__esModule.default (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:57:19)
at __webpack_require__ (/Users/aarthi.ananth/reactjs/reactjs/reaact-csp/CSP/public/build/server.js:30:30)

This is my package.json file

var propTypes = {
  href: _react2['default'].PropTypes.string,
  onClick: _react2['default'].PropTypes.func,
  disabled: _react2['default'].PropTypes.bool,
  role: _react2['default'].PropTypes.string,
  tabIndex: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.number, _react2['default'].PropTypes.string]),
  /**
   * this is sort of silly but needed for Button
   */
  componentClass: _elementType2['default']
};

May I know where I am going wrong..

1 个答案:

答案 0 :(得分:1)

package.json文件中缺少

"prop-types": "^15.6.0"依赖项。在项目中执行以下命令进行安装。

npm install --save prop-types