6
在部署到Heroku時,出現「錯誤:無法找到模塊」錯誤。Heroku + browserify-rails:錯誤:找不到模塊
//的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"
}
}
這是日誌當我運行 「混帳推Heroku的主人」
remote: -----> Build succeeded!
remote: ├── [email protected]
remote: ├── [email protected]
remote: ├── [email protected]
remote: ├── [email protected]
remote: ├── [email protected]
remote: ├── [email protected]
remote: └── [email protected]
後,我得到這個錯誤。
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
//應用程序/資產/ Java腳本/組件/ 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
從日誌,我可以找出以下行有一定的問題。
var ImageGallery = require('react-image-gallery');
但我不知道它爲什麼會導致錯誤。 你對如何解決這個問題有任何想法嗎?
你有沒有想出解決辦法? – stellard
我無法解決問題,因此畢竟我部署到了AWS。我需要在「npm install」之後執行「npm install --save react-image-gallery」,而我無法在Heroku上完成。 –
我有類似的問題。我剛剛死在一個小小的...... :( – blushrt