travis 无法构建,因为错误:找不到模块“react-test-renderer/shallow”
Posted
技术标签:
【中文标题】travis 无法构建,因为错误:找不到模块“react-test-renderer/shallow”【英文标题】:travis cannot build because Error: Cannot find module 'react-test-renderer/shallow' 【发布时间】:2017-09-09 23:56:24 【问题描述】:npm run test
在本地运行良好。
然而,travis 坚持认为构建失败并显示以下日志:
react-test-renderer is an implicit dependency in order to support react@15.5+. Please add the appropriate version to your devDependencies. See https://github.com/airbnb/enzyme#installation
No coverage information was collected, exit without writing coverage information
/home/travis/build/abdennour/react-csv/node_modules/enzyme/build/react-compat.js:159
throw e;
^
Error: Cannot find module 'react-test-renderer/shallow'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /home/travis/build/abdennour/react-csv/node_modules/enzyme/build/react-compat.js:151:34
at Object.<anonymous> (/home/travis/build/abdennour/react-csv/node_modules/enzyme/build/react-compat.js:219:5)
有什么想法吗?知道我的依赖是:
"devDependencies":
"babel-cli": "^6.18.0",
"babel-core": "^6.18.2",
"babel-istanbul": "^0.11.0",
"babel-loader": "^6.2.8",
"babel-plugin-react-html-attrs": "^2.0.0",
"babel-plugin-syntax-decorators": "^6.13.0",
"babel-plugin-transform-class-properties": "^6.19.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-3": "^6.16.0",
"browserify": "^13.3.0",
"console-info": "0.0.4",
"coveralls": "^2.11.15",
"css-loader": "^0.26.1",
"enzyme": "^2.6.0",
"expect": "^1.20.2",
"extract-text-webpack-plugin": "^1.0.1",
"isparta-loader": "^2.0.0",
"jsdom": "9.8.3",
"jsdom-global": "2.1.0",
"mocha": "^3.2.0",
"mocha-lcov-reporter": "^1.2.0",
"react": "^15.4.1",
"react-addons-test-utils": "^15.4.1",
"react-docgen": "^2.13.0",
"react-dom": "^15.4.1",
"react-styleguidist": "^4.6.3",
"sass-loader": "^4.0.2",
"sinon": "^1.17.6",
"style-loader": "^0.13.1",
"uglify-js": "^2.7.5",
"webpack": "^1.13.3",
"webpack-dev-middleware": "^1.8.4",
"webpack-dev-server": "^1.16.2",
"webpack-hot-middleware": "^2.13.2"
【问题讨论】:
【参考方案1】:今天也遇到了同样的问题。
看起来 react-addons-test-utils 已被弃用 https://www.npmjs.com/package/react-addons-test-utils
您可能可以将 package.json 中的那一行替换为
"react-test-renderer": "^15.5.4"
https://www.npmjs.com/package/react-test-renderer
希望有帮助!
【讨论】:
很棒的 @Anthony .. 可能这个 pull-request 对任何想要相应升级软件包的人都有用。【参考方案2】:只是我想详细说明@Anthony 的答案并深入探讨:
所以,这是应该完成的all updates:
升级 react
、react-dom
和 enzyme
。
替换 react-addons-test-utils
为react-test-renderer
。
并且here 构建是通过 Travis 传递的。
【讨论】:
以上是关于travis 无法构建,因为错误:找不到模块“react-test-renderer/shallow”的主要内容,如果未能解决你的问题,请参考以下文章
Travis CI - 无法查询测试包中的测试用例列表:找不到测试包
在travis CI上运行Makefile时找不到gcc命令