参考:https://stackoverflow.com/questions/55816842/the-asset-ckeditor-init-js-is-not-present-in-the-asset-pipeline

使用CKeditor的时候,出现报错

使用命令:

rake assets:precompile

然后出现报错:

Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`

 

那么继续解决问题,使用命令进行更新:

 

yarn install --frozen-lockfile

继续报错

yarn install --frozen-lockfile
yarn install v1.22.19
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

那么尝试使用命令:

yarn install

然后继续运行第一条命令,继续报错:

rake assets:precompile
yarn install v1.22.19
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.28s.
Compiling...
Compilation failed:
ModuleNotFoundError: Module not found: Error: Can't resolve '@rails/activestorage' in '

使用bundle进行更新:

bundle exec rake assets:precompile
yarn install v1.22.19
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.30s.
Everything's up-to-date. Nothing to do

浏览器页面还是报错

然后,前端不需要进行富文本编辑器,删除application的引用即可

-    <%= javascript_include_tag :ckeditor %>