travis cannot build because Error: Cannot find mod

2019-02-24 01:24发布

问题:

The npm run test works fine locally.

However , travis insists that the build is failed and it shows the following log :

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)

Any idea ? known that my dependencies are :

  "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:

Just ran into the same issue today as well.

looks like react-addons-test-utils was deprecated https://www.npmjs.com/package/react-addons-test-utils

You can probably get away with replacing that line in your package.json with

"react-test-renderer": "^15.5.4"

https://www.npmjs.com/package/react-test-renderer

Hope that helps!



回答2:

Just i want to elaborate answer of @Anthony and dive on it :

So , this is all updates that should be done :

  • Upgrade react, react-dom and enzyme .

  • Replace react-addons-test-utils by react-test-renderer .

And here the build was passing via Travis.