尝试编译时,所有图像均出现以下错误:
const names = {
animals: ['Dog', 'Cat', 'Snake'],
flowers: ['Rose', 'Daisy']
};
const res = Object.entries(names)
.reduce(
({type, subtype}, [key, values]) => ({
type: type.concat(key),
subtype: subtype.concat(values)
}),
{ type: [], subtype: [] } // Starting value
);
console.log(res);
rails assets:precompile
所以我得到
ModuleNotFoundError: Module not found: Error: Can't resolve 'core-js/modules/es.symbol' in '/***/app/javascript/packs'
Field 'browser' doesn't contain a valid alias configuration
/*/app/javascript/core-js/modules/es.symbol.scss doesn't exist
.css
Field 'browser' doesn't contain a valid alias configuration
/*/app/javascript/core-js/modules/es.symbol.css doesn't exist
.module.sass
Field 'browser' doesn't contain a valid alias configuration
/*/app/javascript/core-js/modules/es.symbol.module.sass doesn't exist
.module.scss
Field 'browser' doesn't contain a valid alias configuration
/*/app/javascript/core-js/modules/es.symbol.module.scss doesn't exist
.module.css
Field 'browser' doesn't contain a valid alias configuration
/*/app/javascript/core-js/modules/es.symbol.module.css doesn't exist
.png
Field 'browser' doesn't contain a valid alias configuration
/*/app/javascript/core-js/modules/es.symbol.png doesn't exist
.svg
我已经通过添加我的gemfile安装了webpacker
Webpacker::Manifest::MissingEntryError in Pages#home
和
gem 'webpacker'
未创建app / javascript中的文件夹包,所以我自己创建了它,并将当前在app / assets中的application.js添加到app / javascript / packs /
我将此添加到了文件的顶部:
bundle
bundle exec rails webpacker:install
yarn upgrade
yarn install
我确实将所有标签替换为
import 'core-js/stable'
import 'regenerator-runtime/runtime'
const images = require.context('../images', true)
const imagePath = (name) => images(name, true)
或
javascript_pack_tag
但是我的清单文件仍然看起来像:
asset_pack_path
在没有进行任何更改的情况下,图像显然已正确编译,并且当我可以访问我的应用程序时,javascript无法正常工作。
答案 0 :(得分:2)
删除此文件和文件夹:
/node_modules
/tmp/cache
yarn.lock
Gemfile.lock
然后运行:
bundle install
rails webpacker:install
rails assets:precompile
rails webpacker:compile