• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

什么时候开始npm我得到TypeError:无法读取undefined属性’string’

node.js 来源:Aarthi Ananth 3次浏览

我已经安装了节点js和mongo db,之后我开始了节点js。当我启动节点js时,我得到这个错误。这个错误是从server.js文件中抛出的。但我无法确定哪一行是抛出错误。什么时候开始npm我得到TypeError:无法读取undefined属性’string’

/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) 

我server.js文件具有行22403

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'] 
}; 

下面的代码这是我的package.json文件

{ 
"name": "isomorphicdemo", 
"version": "1.1.1", 
"description": "React Customer care application", 
"main": "src/server/app.js", 
"scripts": { 
"start": "nodemon public/build/server.js" 
}, 
    "files": [ 
    "lib/", 
    "socket.io.js" 
], 
"dependencies": { 
"babel-core": "^6.26.0", 
"babel-loader": "^7.1.2", 
"babel-plugin-dev-expression": "^0.2.1", 
"babel-preset-es2015": "^6.16.0", 
"babel-preset-react": "^6.16.0", 
"babel-runtime": "^6.26.0", 
"babelify": "^8.0.0", 
"body-parser": "^1.15.2", 
"bootbox": "^4.4.0", 
"browserify": "^14.5.0", 
"deep-equal": "^1.0.1", 
"ejs": "^2.3.3", 
"ejs-loader": "^0.3.0", 
"engine.io-client": "^3.1.4", 
"express": "^4.13.3", 
"express-session": "^1.14.1", 
"express-useragent": "^1.0.3", 
"flux": "^3.1.3", 
"gulp-live-server": "0.0.31", 
"history": "^4.7.2", 
"http-proxy": "^1.11.1", 
"invariant": "^2.1.0", 
"jquery": "^3.1.1", 
"json-loader": "^0.5.2", 
"prop-types": "^15.6.0", 
"react": "^16.2.0", 
"react-bootstrap": "^0.31.5", 
"react-dom": "^16.2.0", 
"react-flux": "^1.0.1", 
"react-native-version-check": "^2.0.1", 
"react-router": "^4.2.0", 
"reactify": "^1.1.1", 
"simple-react-button": "^1.3.0", 
"socket.io-client": "^2.0.4", 
"style-loader": "^0.19.0", 
"stylus-loader": "^3.0.1", 
"superagent": "^3.8.1", 
"vinyl-source-stream": "^1.1.0", 
"warning": "^3.0.0", 
"webpack": "^3.9.1", 
"websocket": "^1.0.23", 
"ws": "^3.3.2" 
}, 
"devDependencies": { 
    "browser-sync": "^2.9.6", 
    "gulp": "^3.9.0", 
    "gulp-babel": "^7.0.0", 
    0"nodemon": "^1.7.0" 
} 
} 

可我知道我要去的地方错了..


===========解决方案如下:

"prop-types": "^15.6.0" package.json文件中缺少依赖关系。在您的项目中执行下面的命令来安装它。

npm install --save prop-types


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)