在我的Rails 6项目中,我添加了jQuery pushMenu,
Yarn添加按钮菜单
从https://www.npmjs.com/package/push-menu现在,我可以看到这在节点模块文件夹,作为推菜单。然而,当我试图导入或包括从包,如:
require("push-menu")
我得到以下错误:
Uncaught Error: Cannot find module 'push-menu'
at webpackMissingModule (application.js:12)
at Module../app/javascript/packs/application.js (application.js:12)
at __webpack_require__ (bootstrap:19)
at bootstrap:83
at bootstrap:83
我的package.json文件看起来像这样
//package.json file
{
"name": "example_setup",
"private": true,
"dependencies": {
"@rails/actioncable": "^6.0.0-alpha",
"@rails/activestorage": "^6.0.0-alpha",
"@rails/ujs": "^6.0.0-alpha",
"@rails/webpacker": "^4.0.7",
"jquery": "^3.4.1",
"push-menu": "^2.0.8",
"select2": "^4.0.7",
"turbolinks": "^5.2.0"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3.7.1"
}
}
我做错了什么?
1条答案
按热度按时间ui7jx7zq1#
看起来,按钮菜单模块损坏:
它定义了一个“app/index.js”作为主索引文件:
但在node_modules文件夹中没有
node_modules/app/index.js
尝试按如下方式导入: