- rails 7.1
- vite
- Jenkinsfile
上記な環境でJenkinsのビルドを実行すると、以下のようなエラーに遭遇する。
ActionView::Template::Error: Vite Ruby can't find entrypoints/application.js in the manifests.
Possible causes:
- The last build failed. Try running `bin/vite build --clear --mode=test` manually and check for errors.
Errors:
npm error code EACCES
npm error syscall mkdir
npm error path /.npm
npm error errno EACCES
npm error
npm error Your cache folder contains root-owned files, due to a bug in
npm error previous versions of npm which has since been addressed.
npm error
npm error To permanently fix this problem, please run:
npm error sudo chown -R XXX:XXX "/.npm"
npm error Log files were not written due to an error writing to the directory: /.npm/_logs
npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
Visit the Troubleshooting guide for more information:
https://vite-ruby.netlify.app/guide/troubleshooting.html#troubleshooting
Jenkinsfileファイルを以下のようにすることで解消した。
environment {
RAILS_ENV = 'test'
NPM_CONFIG_CACHE = "${WORKSPACE}/.npm"
}
steps {
sh 'bundle exec vite install'
sh 'bin/vite build --clear --mode=test'
sh 'bundle exec rails test'
}