您的位置:首页技术文章
文章详情页

javascript - react运行报错

【字号: 日期:2023-09-15 11:43:29浏览:44作者:猪猪

问题描述

另一篇提问/q/10...

这是我的配置

{ 'name': 'mantaweb', 'version': '1.0.0', 'description': '', 'main': 'web/index.html', 'scripts': { 'build': './node_modules/.bin/webpack --config webpack/webpack.build.config.js --progress --colors', 'dev': './node_modules/.bin/webpack-dev-server --config webpack/webpack.dev.config.js --progress --colors --inline --hot --host 10.1.240.18', 'home': './node_modules/.bin/webpack-dev-server --config webpack/webpack.dev.config.js --progress --colors --inline --hot --host 192.168.5.102', 'gz': './node_modules/.bin/webpack-dev-server --config webpack/webpack.dev.config.js --progress --colors --inline --hot --host 192.168.1.109', 'local': './node_modules/.bin/webpack-dev-server --config webpack/webpack.dev.config.js --progress --colors --inline --hot' }, 'author': 'Shaohua.Gu', 'license': 'wrapbootstrap', 'homepage': '', 'devDependencies': { 'antd': '^2.1.0', 'autoprefixer': '^6.3.6', 'autoprefixer-loader': '^3.2.0', 'babel-core': '^6.17.0', 'babel-loader': '^6.2.5', 'babel-plugin-antd': '^0.5.1', 'babel-plugin-import': '^1.0.1', 'babel-plugin-transform-object-rest-spread': '^6.6.5', 'babel-preset-es2015': '^6.6.0', 'babel-preset-react': '^6.5.0', 'classnames': '^2.2.3', 'clean-webpack-plugin': '^0.1.8', 'copy-to-clipboard': '^3.0.5', 'css-loader': '^0.23.1', 'echarts': '^3.2.2', 'file-loader': '^0.8.5', 'history': '^2.0.1', 'jquery': '^2.2.2', 'jquery-slimscroll': '^1.3.6', 'json-loader': '^0.5.4', 'less': '^2.6.1', 'less-loader': '^2.2.3', 'lodash': '^4.6.1', 'moment': '^2.15.1', 'postcss-loader': '^0.8.2', 'precss': '^1.4.0', 'react': '^15.3.2', 'react-bootstrap-validation': '^0.1.11', 'react-copy-to-clipboard': '^4.1.0', 'react-dom': '^15.3.2', 'react-hot-loader': '^1.3.0', 'react-markdown': '^2.2.0', 'react-router': '^2.8.1', 'redux': '^3.3.1', 'reflux': '^0.4.0', 'style-loader': '^0.13.1', 'url-loader': '^0.5.7', 'webpack': '^1.15.0', 'webpack-dev-server': '^1.14.1', 'yargs': '^4.3.2' }, 'dependencies': { 'autoprefixer': '^6.7.7', 'clean-webpack-plugin': '^0.1.16', 'lodash': '^4.17.4', 'precss': '^1.4.0', 'press': '0.0.2', 'react': '^0.14.7', 'react-dom': '^15.5.4', 'yargs': '^4.8.1' }}

========================================================npm run build 爆了下面的警告

WARNING in ./~/react/dist/react.min.jsCritical dependencies:12:407-414 This seems to be a pre-built javascript file. Though this is possible, it’s not recommended. Try to require the original source to get better results. @ ./~/react/dist/react.min.js 12:407-414WARNING in ./~/react-dom/dist/react-dom.min.jsCritical dependencies:12:478-485 This seems to be a pre-built javascript file. Though this is possible, it’s not recommended. Try to require the original source to get better results. @ ./~/react-dom/dist/react-dom.min.js 12:478-485

========================================================================npm run local 爆了警告

ERROR in ./~/react-dom/lib/ReactDOMUnknownPropertyHook.jsModule not found: Error: Cannot resolve ’file’ or ’directory’ E:heShengWebmanta-webnode_modulesreactlib/ReactComponentTreeHook in E:heShengWebmanta-webnode_modulesreact-domlib @ ./~/react-dom/lib/ReactDOMUnknownPropertyHook.js 15:29-72ERROR in ./~/react-dom/lib/ReactDOMNullInputValuePropHook.jsModule not found: Error: Cannot resolve ’file’ or ’directory’ E:heShengWebmanta-webnode_modulesreactlib/ReactComponentTreeHook in E:heShengWebmanta-webnode_modulesreact-domlib @ ./~/react-dom/lib/ReactDOMNullInputValuePropHook.js 13:29-72ERROR in ./~/react-dom/lib/ReactDOMInvalidARIAHook.jsModule not found: Error: Cannot resolve ’file’ or ’directory’ E:heShengWebmanta-webnode_modulesreactlib/ReactComponentTreeHook in E:heShengWebmanta-webnode_modulesreact-domlib @ ./~/react-dom/lib/ReactDOMInvalidARIAHook.js 14:29-72ERROR in ./~/react-dom/lib/ReactDebugTool.jsModule not found: Error: Cannot resolve ’file’ or ’directory’ E:heShengWebmanta-webnode_modulesreactlib/ReactComponentTreeHook in E:heShengWebmanta-webnode_modulesreact-domlib @ ./~/react-dom/lib/ReactDebugTool.js 16:29-72ERROR in ./~/react-dom/lib/instantiateReactComponent.jsModule not found: Error: Cannot resolve ’file’ or ’directory’ E:heShengWebmanta-webnode_modulesreactlib/getNextDebugID in E:heShengWebmanta-webnode_modulesreact-domlib @ ./~/react-dom/lib/instantiateReactComponent.js 20:21-56ERROR in ./~/react-dom/lib/ReactChildReconciler.jsModule not found: Error: Cannot resolve ’file’ or ’directory’ E:heShengWebmanta-webnode_modulesreactlib/ReactComponentTreeHook in E:heShengWebmanta-webnode_modulesreact-domlib @ ./~/react-dom/lib/ReactChildReconciler.js 29:27-70 37:31-74ERROR in ./~/react-dom/lib/flattenChildren.jsModule not found: Error: Cannot resolve ’file’ or ’directory’ E:heShengWebmanta-webnode_modulesreactlib/ReactComponentTreeHook in E:heShengWebmanta-webnode_modulesreact-domlib @ ./~/react-dom/lib/flattenChildren.js 26:27-70 42:33-76ERROR in ./~/react-dom/lib/checkReactTypeSpec.jsModule not found: Error: Cannot resolve ’file’ or ’directory’ E:heShengWebmanta-webnode_modulesreactlib/ReactComponentTreeHook in E:heShengWebmanta-webnode_modulesreact-domlib @ ./~/react-dom/lib/checkReactTypeSpec.js 29:27-70 71:37-80webpack: Failed to compile.我到底哪里有问题呢,公司的电脑可以运行,我把代码git clone到自己的电脑上运行就爆了怎么多问题,我还把node_modules删了,重新npm install都不行:X

问题解答

回答1:

package.json 中 dependencies 和 devDependencies 有两套 react 和 react-dom 的版本.

你看下 node_modules/react 的版本两台电脑之间是否有差异.

如果有 yarn.lock 可以通过 yarn install 安装,确保版本相同.

标签: JavaScript
相关文章: