简体   繁体   English

如何在 Rails 6 和 webpacker 中使用 morris.js?

[英]How do I use morris.js with Rails 6 and webpacker?

I'm not new to Rails, but I'm new to Rails 6 & webpacker.我不是 Rails 新手,但我是 Rails 6 和 webpacker 的新手。 I'm trying to integrate morris.js (and raphael.js) into my app.我正在尝试将 morris.js(和 raphael.js)集成到我的应用程序中。 I've done:我弄完了:

 yarn add raphael
 yarn add morris

In app/views/layouts/application.html.erb在 app/views/layouts/application.html.erb

<%= javascript_pack_tag 'raphael' %>
<%= javascript_pack_tag 'morris' %>

This is my error:这是我的错误:

Webpacker can't find raphael in /Users/jarvis/rails/stuper/public/packs/manifest.json. Webpacker 在 /Users/jarvis/rails/stuper/public/packs/manifest.json 中找不到 raphael。 Possible causes:可能的原因:

  1. You want to set webpacker.yml value of compile to true for your environment unless you are using the webpack -w or the webpack-dev-server.除非您使用webpack -w或 webpack-dev-server,否则您希望为您的环境将 compile 的 webpacker.yml 值设置为 true。
  2. webpack has not yet re-run to reflect updates. webpack 尚未重新运行以反映更新。
  3. You have misconfigured Webpacker's config/webpacker.yml file.您错误地配置了 Webpacker 的 config/webpacker.yml 文件。
  4. Your webpack configuration is not creating a manifest.您的 webpack 配置没有创建清单。 Your manifest contains:您的清单包含:

got it working by得到它的工作

rm -rf node_modules
yarn install

then i simply added morris-rails and raphael-rails gems然后我简单地添加了 morris-rails 和 raphael-rails gems

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM