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

报错信息:

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

posted @ 2019-11-06 18:52  木子章  阅读(1704)  评论(0编辑  收藏  举报