You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Rails 5.1.6资产加载报错求助:Errno::ENOENT文件不存在

Fixing Errno::ENOENT with ExecJS in Rails 5.1.6 (Windows)

Hey there, that ExecJS temp file error is super frustrating—let's break down what's going on and fix it. This issue usually pops up on Windows because the default ExecJS runtime (JScript, Windows' built-in JS engine) has trouble cleaning up temporary files, either due to permission locks or naming conflicts. Here are a few reliable solutions:

The easiest long-term fix is to use Node.js instead of the default Windows JScript. It's more stable for Rails asset compilation:

  • Download and install the latest LTS version of Node.js (make sure to check "Add to PATH" during installation)
  • Restart your command prompt/terminal and Rails server so the system picks up Node's path
  • ExecJS will automatically detect Node and use it instead, bypassing the temp file cleanup issues entirely

2. Modify ExecJS temp file naming (no extra software needed)

If you don't want to install Node, you can tweak how ExecJS names its temp files to avoid conflicts. Create an initializer file in your Rails project:

  • Create config/initializers/execjs.rb
  • Paste this code into the file:
module ExecJS
  module Runtime
    class JScript
      def tempfile_name
        File.join(Dir.tmpdir, "execjs.#{$$}.#{Thread.current.object_id}.#{rand(1000000)}.js")
      end
    end
  end
end
  • Save the file and restart your Rails server. This changes the temp file naming pattern to reduce the chance of file locks or deletion failures.

3. Verify Temp Folder Permissions

Sometimes Windows restricts access to your temp folder, preventing ExecJS from deleting files:

  • Navigate to C:/Users/Bastian/AppData/Local/Temp
  • Right-click the folder, select Properties > Security
  • Make sure your user account has Modify or Full Control permissions for the folder
  • If not, click Edit to add your user and grant the necessary permissions, then click Apply

After trying any of these solutions, reload your Rails app's view—you should no longer see that Errno::ENOENT error.

内容的提问来源于stack exchange,提问作者xploited

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:28:08