2

我在将带有 webpacker 和 vue 的简单 Rails 应用程序部署到 digitalocean 液滴时遇到问题。

一旦我将 moment 依赖项添加到 vue 组件,服务器上的编译过程就会失败。(没有输出)我不知道如何找到解决方案。

我在 main.js 中添加依赖项的方式:

import moment from 'moment';
Vue.prototype.$moment = moment

以及我如何在组件中使用它:

this.score.day = this.$moment().format('YYYY-MM-DD');

'RAILS_ENV=production bin/bundle exec rake assets:precompile --trace' 在服务器上的输出

** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke yarn:install (first_time)
** Execute yarn:install
yarn install v1.1.0
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.85s.
** Execute assets:precompile
** Invoke webpacker:compile (first_time)
** Invoke webpacker:verify_install (first_time)
** Invoke webpacker:check_node (first_time)
** Execute webpacker:check_node
** Invoke webpacker:check_yarn (first_time)
** Execute webpacker:check_yarn
** Invoke webpacker:check_binstubs (first_time)
** Execute webpacker:check_binstubs
** Execute webpacker:verify_install
Webpacker is installed  
Using /var/www/beleep-2/config/webpacker.yml file for setting up webpack paths
** Invoke environment 
** Execute webpacker:compile
Compiling…
Compilation failed:

在组件中添加依赖项的其他方法会导致相同的问题。在我的笔记本电脑上,一切都在开发模式下完美运行。希望你们中的任何人都能指出我正确的方向来解决这个问题?!

4

1 回答 1

1

通过在我的开发笔记本电脑上进行预编译解决了这个问题。有关更多信息,请参阅:this github issue

于 2017-10-18T13:34:05.877 回答