解决rails报错:Webpacker::Manifest::MissingEntryError in Projects#index

北城以北 提交于 2019-12-03 20:33:34

报错信息:

Webpacker can't find application.js in .../app/public/packs/manifest.json. 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.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}

报错原因:node.js版本太低

在用rails new project_name命令生成项目目录时会看到一个node.js版本警告信息(项目生成时注意看命令行的打印信息,后面新建一个项目时才看到)

1. 更新node.js

1.1 输入命令sudo npm config set registry https://registry.npm.taobao.org,把npm的包源设置为淘宝的镜像
1.2 输入命令sudo npm install n -g,来安装n这个工具,n这个工具是用于更新node版本的工具
1.3 输入命令sudo n stable,安装最新稳定版的nodejs

2. 安装Webpacker

输入命令bundle exec rake webpacker:install

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!