简体   繁体   English

Heroku + browserify-rails:错误:找不到模块

[英]Heroku + browserify-rails: Error: Cannot find module

While deploying to Heroku, I got "Error: Cannot find module" error. 在部署到Heroku时,我收到“错误:找不到模块”错误。

// package.json // 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" 这是我运行“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 // 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 the line below has some problem. 从日志中,我可以看出下面的行有一些问题。

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

But I don't know why it causes an error. 但我不知道它为什么会导致错误。 Do you have any idea on how to solve this problem? 你对如何解决这个问题有任何想法吗?

I got a similar error while trying to run an npm run compile with Browserify and react. 尝试使用Browserify运行npm run compile时出现了类似的错误并做出反应。

It was not able to recognize my react gem even after doing an npm install . 即使在进行npm install后,也无法识别我的反应宝石。

What I did was: 我做的是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 browserify-rails错误 - Error with browserify-rails 使用browserify-rails包含样式表 - Include stylesheets using browserify-rails 当我需要使用browserify-rails时,formsy-react npm模块会中断rails应用程序 - formsy-react npm module breaks rails app when I require it using browserify-rails 需要使用Browserify和browserify-rails的sprockets预处理文件 - Requiring a sprockets-preprocessed file with Browserify and browserify-rails env:node \\ r:没有这样的文件或目录,带有browserify-rails - env: node\r: No such file or directory with browserify-rails 尝试使用browserify-rails时资产编译失败 - Failed asset compilation when attempting to use browserify-rails 链轮// = require和browserify-rails require()之间的区别? - Difference between sprockets //=require and browserify-rails require()? 使用gem browserify-rails时,它不反映文件更改 - When using gem browserify-rails, it does not reflect file changes babelify + browserify-rails + react,Uncaught SyntaxError:意外的令牌导入 - babelify + browserify-rails + react, Uncaught SyntaxError: Unexpected token import 将我的Rails应用程序部署到heroku时遇到问题“错误:找不到模块&#39;@ rails / webpacker&#39;” - Having trouble deploying my rails app to heroku “Error: Cannot find module '@rails/webpacker'”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM