部署部署我在瀏覽器控制檯有以下錯誤之前工作後:軌道4 - JavaScript沒有在Heroku
ReferenceError: require is not defined npm.self-...js:2:0
儘管這樣,我的本地服務器上的JavaScript運行完美。當我在heroku上部署我的應用程序時,它不會,但是css會,所以我不確定資產管道引起的問題。我有
group :production do
gem 'pg'
gem 'rails_12factor'
end
在我的Gemfile中。我試圖在本地預編譯資產,甚至通過「heroku run」命令,但它沒有改變任何東西。這裏是我的application.js:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require moment
//= require bootstrap-datetimepicker
$(function() {
$("#datetimepicker").datetimepicker({
locale: "en",
format: "lll"
});
});
$(function() {
$("#events").on("click", ".pager a", function() {
$.getScript(this.href);
return false;
});
});
而且npm.js:
// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
require('../../js/transition.js')
require('../../js/alert.js')
require('../../js/button.js')
require('../../js/carousel.js')
require('../../js/collapse.js')
require('../../js/dropdown.js')
require('../../js/modal.js')
require('../../js/tooltip.js')
require('../../js/popover.js')
require('../../js/scrollspy.js')
require('../../js/tab.js')
require('../../js/affix.js')
如果你要問我可以共享GitHub的鏈接。謝謝!
你有預編譯資產嗎? –
@GaganGami是的,但預編譯似乎不起作用。 –