Heroku + browser rails: error: cannot find module

During deployment to Heroku, I received the error "Error: I can not find the module."

//package.json

{ "name": "AppName", "version": "1.0.0", "description": "== README", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "somerepo.git" }, "author": "", "license": "ISC", "dependencies": { "browserify": "^11.0.1", "browserify-incremental": "^3.0.1", "object-assign": "^3.0.0", "react": "^0.13.3", "react-image-gallery": "^0.4.1", "reactify": "^1.1.1", "superagent": "^1.3.0" }, "devDependencies": { "es6-promise": "^2.3.0" } } 

This is the log when I run "git push heroku master"

 remote: -----> Build succeeded! remote: ├── browserify@11.0.1 remote: ├── browserify-incremental@3.0.1 remote: ├── object-assign@3.0.0 remote: ├── react@0.13.3 remote: ├── react-image-gallery@0.4.1 remote: ├── reactify@1.1.1 remote: └── superagent@1.3.0 

After that I got this error.

 remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: AssetSync: using /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/config/initializers/asset_sync.rb remote: [DEPRECATION] requiring "RMagick" is deprecated. Use "rmagick" instead remote: I, [2015-08-08T08:09:07.998223 #595] INFO -- : Writing /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/public/assets/app.js-a57be479852c067f49ad0f930156917fbc753d782ac615de774d5f037964dcfe.jsx remote: Browserify: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/node_modules/.bin/browserify -t reactify --extension=".js.jsx, .react.jsx, .jsx" -r react --list -o "/tmp/build_65611fbfcf2cb3d9c9e2addc22015359/tmp/cache/browserify-rails/output20150808-595-41bgqb" - remote: rake aborted! remote: BrowserifyRails::BrowserifyError: Error while running `/tmp/build_65611fbfcf2cb3d9c9e2addc22015359/node_modules/.bin/browserify -t reactify --extension=".js.jsx, .react.jsx, .jsx" -r react --list -o "/tmp/build_65611fbfcf2cb3d9c9e2addc22015359/tmp/cache/browserify-rails/ output20150808-595-41bgqb" -`: remote: events.js:85 remote: throw er; // Unhandled 'error' event remote: ^ remote: Error: Cannot find module 'react-image-gallery' from '/tmp/build_65611fbfcf2cb3d9c9e2addc22015359/app/assets/javascripts/components' remote: at /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/node_modules/browserify/node_modules/resolve/lib/async.js:46:17 remote: at process (/tmp/build_65611fbfcf2cb3d9c9e2addc22015359/node_modules/browserify/node_modules/resolve/lib/async.js:173:43) remote: at ondir (/tmp/build_65611fbfcf2cb3d9c9e2addc22015359/node_modules/browserify/node_modules/resolve/lib/async.js:188:17) remote: at load (/tmp/build_65611fbfcf2cb3d9c9e2addc22015359/node_modules/browserify/node_modules/resolve/lib/async.js:69:43) remote: at onex (/tmp/build_65611fbfcf2cb3d9c9e2addc22015359/node_modules/browserify/node_modules/resolve/lib/async.js:92:31) remote: at /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/node_modules/browserify/node_modules/resolve/lib/async.js:22:47 remote: at FSReqWrap.oncomplete (fs.js:95:15) remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/browserify-rails-1.2.0/lib/browserify-rails/browserify_processor.rb:177:in `run_browserify' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/browserify-rails-1.2.0/lib/browserify-rails/browserify_processor.rb:113:in `dependencies' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/browserify-rails-1.2.0/lib/browserify-rails/browserify_processor.rb:90:in `commonjs_module?' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/browserify-rails-1.2.0/lib/browserify-rails/browserify_processor.rb:70:in `should_browserify?' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/browserify-rails-1.2.0/lib/browserify-rails/browserify_processor.rb:23:in `evaluate' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/legacy_tilt_processor.rb:25:in `call' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:75:in `call_processor' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in `reverse_each' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in `call_processors' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:86:in `load_asset_by_uri' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:45:in `block in load' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:155:in `fetch_asset_from_dependency_cache' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:38:in `load' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:20:in `block in initialize' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:47:in `yield' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:47:in `load' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/bundle.rb:23:in `block in call' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/utils.rb:183:in `dfs' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/bundle.rb:24:in `call' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:75:in `call_processor' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in `reverse_each' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/processor_utils.rb:56:in `call_processors' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:86:in `load_asset_by_uri' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:45:in `block in load' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:155:in `fetch_asset_from_dependency_cache' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/loader.rb:38:in `load' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:20:in `block in initialize' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:47:in `yield' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/cached_environment.rb:47:in `load' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/base.rb:63:in `find_asset' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/base.rb:70:in `find_all_linked_assets' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:138:in `block in find' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:223:in `block in stat_tree' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:207:in `block in stat_directory' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:204:in `each' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:204:in `stat_directory' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/path_utils.rb:222:in `stat_tree' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:105:in `each' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:105:in `block in logical_paths' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:104:in `each' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/legacy.rb:104:in `logical_paths' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:136:in `find' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/sprockets/manifest.rb:162:in `compile' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-3.2.0/lib/rake/sprocketstask.rb:147:in `with_logger' remote: /tmp/build_65611fbfcf2cb3d9c9e2addc22015359/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define' remote: Tasks: TOP => assets:precompile remote: (See full trace by running task with --trace) remote: ! remote: ! Precompiling assets failed. remote: ! remote: remote: ! Push rejected, failed to compile Ruby app 

//app/assets/javascripts/components/ImageSlider.js.jsx

 var React = require('react'); var ImageGallery = require('react-image-gallery'); var request = require('superagent'); var ImageSlider = React.createClass({ getInitialState: function() { return { tourImages: [] } }, componentDidMount: function() { var currentPath = window.location.pathname; console.log(currentPath); var tempArray = currentPath.split('/'); var tourId = parseInt(tempArray[tempArray.length-1]); this._fetchImages(tourId); }, _fetchImages: function(tourId) { var _this = this; request .get('some_end_point/' + tourId + '/fetch_images') .end(function(err, res) { if (res.ok) { _this.setState({ tourImages: res.body.tourImages }) console.log(_this.state.tourImages); } }) }, render: function () { var tourImages = this.state.tourImages; var tourImageList = []; for (var i = 0; i <= tourImages.length - 1; i++) { tourImageList.push({original: tourImages[i].tour_photo.large.url, thumbnail: tourImages[i].tour_photo.small.url}) } var options = { items: tourImageList }; return ( <ImageGallery {...options} /> ); } }); module.exports = ImageSlider 

From the log I can find out that the line below has some problems.

 var ImageGallery = require('react-image-gallery'); 

But I do not know why this causes an error. Do you know how to solve this problem?

+6
source share
1 answer

I got a similar error trying to run npm run compile using Browserify and respond.

It could not recognize my rocket even after npm install .

What I've done:

 rm -rf node_modules #to clean out stale node modules, and then npm update 
0
source

All Articles