webpacker: asset_compile fails during yarn install

We are using beanstalk as our server. When deploying the logs, we get the following

  [1/4] Resolving packages...
  Webpacker is installed 🎉 🍰
  Using /var/app/ondeck/config/webpacker.yml file for setting up webpack paths
  Compiling…
  Compilation failed:
  
  ./bin/webpack:26:in `exec': No such file or directory - /var/app/ondeck/node_modules/.bin/webpack (Errno::ENOENT)
  	from ./bin/webpack:26:in `block in <main>'
  	from ./bin/webpack:25:in `chdir'
  	from ./bin/webpack:25:in `<main>'
   (Executor::NonZeroExitStatus)

It appears there is an error installing yarn packages as it is not going to step 2 or 4.

When I ssh into the server, go to the ondeck directory, which has the newest code I believe and then I run yarn install, I get:

error An unexpected error occurred: "EACCES: permission denied, mkdir '/var/app/ondeck/node_modules'".```

when I use `sudo yarn install` it works and when I update the permissions with `sudo chmod -R 777 /var/app`, it works. So I tried and add the chmod command to a `.ebextensions config file` but I am having no luck.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 9
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@kolosek may the universe bless your existence. After a seemingly endless amount of turmoil I finally have assets precompiling on EB! Praise the Lord!

Hi, not sure if this is related but I ran into a similar issue (same logs “No such file or directory node_modules/.bin/webpack (Errno::ENOENT)”) on a project that I updated from Rails 4.2 to Rails 5.2.

After digging, here is what was happening:

After adding the bin/yarn file (copied from a Rails 5 project), it worked!

@antoinematyja Your solution worked. For the sake of other developers, here is the content of yarn file that worked for me, by placing it in /bin filder.

#!/usr/bin/env ruby
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
  begin
    exec "yarnpkg", *ARGV
  rescue Errno::ENOENT
    $stderr.puts "Yarn executable was not detected in the system."
    $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
    exit 1
  end
end

@foton You would need to run yarn or yarn install like bundle after cloning since node_modules are ignored. No need to run webpacker:yarn_install, it’s same thing.

@mlennie You need to make sure ./bin/webpack binstub is checked into your source control. This file is generate when you run bundle exec rails webpacker:install