问题
I'm trying to run the "gulp nodemon" to check an application made in REACT but I get the following error:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'react/lib/warning'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/kevin/hbtn/Fix_My_Code_Challenge/0x01-challenge/react-blog/node_modules/react-bootstrap/lib/BreadcrumbItem.js:23:24)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .js] (/home/kevin/hbtn/Fix_My_Code_Challenge/0x01-challenge/react-blog/node_modules/babel/lib/babel/api/register/node.js:130:7)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
It seems that the version of REACT with which it was developed is old and had a different distribution of its files.
This is the file where the error occurs:
'use strict';
var _objectWithoutProperties = require('babel-runtime/helpers/object-without-properties')['default'];
var _extends = require('babel-runtime/helpers/extends')['default'];
var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];
exports.__esModule = true;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var _SafeAnchor = require('./SafeAnchor');
var _SafeAnchor2 = _interopRequireDefault(_SafeAnchor);
var _reactLibWarning = require('react/lib/warning');
var _reactLibWarning2 = _interopRequireDefault(_reactLibWarning);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var createReactClass = require('create-react-class');
var BreadcrumbItem = createReactClass({
displayName: 'BreadcrumbItem',
propTypes: {
/**
* If set to true, renders `span` instead of `a`
*/
active: _propTypes2['default'].bool,
/**
* HTML id for the wrapper `li` element
*/
id: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].number]),
/**
* HTML id for the inner `a` element
*/
linkId: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].number]),
/**
* `href` attribute for the inner `a` element
*/
href: _propTypes2['default'].string,
/**
* `title` attribute for the inner `a` element
*/
title: _propTypes2['default'].node,
/**
* `target` attribute for the inner `a` element
*/
target: _propTypes2['default'].string
},
getDefaultProps: function getDefaultProps() {
return {
active: false
};
},
render: function render() {
var _props = this.props;
var active = _props.active;
var className = _props.className;
var id = _props.id;
var linkId = _props.linkId;
var children = _props.children;
var href = _props.href;
var title = _props.title;
var target = _props.target;
var props = _objectWithoutProperties(_props, ['active', 'className', 'id', 'linkId', 'children', 'href', 'title', 'target']);
_reactLibWarning2['default'](!(href && active), '[react-bootstrap] `href` and `active` properties cannot be set at the same time');
var linkProps = {
href: href,
title: title,
target: target,
id: linkId
};
return _react2['default'].createElement(
'li',
{ id: id, className: _classnames2['default'](className, { active: active }) },
active ? _react2['default'].createElement(
'span',
props,
children
) : _react2['default'].createElement(
_SafeAnchor2['default'],
_extends({}, props, linkProps),
children
)
);
}
});
exports['default'] = BreadcrumbItem;
module.exports = exports['default'];
And this is the package.json file:
{
"name": "React-Isomorphic-Blog",
"version": "1.0.0",
"description": "React Isomorphic Blog",
"author": "Jonathan Rossi <jonathan.m.rossi@gmail.com>",
"license": "MIT",
"dependencies": {
"alt": "^0.14.5",
"babel": "^4.7.16",
"body-parser": "^1.12.3",
"cookie-parser": "^1.3.4",
"create-react-class": "^15.6.3",
"express": "^4.12.3",
"express-session": "^1.10.4",
"iso": "^4.0.2",
"jade": "^1.9.2",
"marked": "^1.1.0",
"moment": "^2.10.2",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-bootstrap": "^0.26.2",
"react-ga": "^2.1.2",
"react-prop-types": "^0.4.0",
"react-router": "^3.2.6",
"superagent": "^5.2.2"
},
"devDependencies": {
"browserify": "^16.5.1",
"gulp": "^4.0.2",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-minify-css": "^1.2.4",
"gulp-nodemon": "^2.0.2",
"gulp-print": "^2.0.1",
"gulp-rename": "^1.2.2",
"gulp-sass": "^4.1.0",
"gulp-uglify": "^1.5.4",
"nodemon": "^1.3.7",
"reactify": "^1.1.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
},
"paths": {
"app": "./src/client.js"
},
"dest": {
"app": "bundle.js",
"dist": "public/scripts/react"
},
"main": "bin/www.js",
"scripts": {
"start": "node --use_strict bin/www.js"
}
}
I'm new to React, I've already solved many other mistakes that have come up, but for this one I couldn't find a solution. Can you help me? Thank you very much.
来源:https://stackoverflow.com/questions/62011074/cannot-find-module-react-lib-warning-error-with-react-version