From 6957452ffc7cb4df9c0b7c0e984d3aa30ddf1688 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Thu, 16 Feb 2023 14:23:29 +0100 Subject: [PATCH] Specify nodes_modules directory for webpack Also align ./bin/webpacker-dev-server and ./bin/webpacker --- bin/webpacker | 3 +++ bin/webpacker-dev-server | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bin/webpacker b/bin/webpacker index 47ef0c4c..767da41d 100755 --- a/bin/webpacker +++ b/bin/webpacker @@ -8,6 +8,9 @@ require "webpacker/webpack_runner" ENV["RAILS_ENV"] ||= "development" ENV["NODE_ENV"] ||= ENV["RAILS_ENV"] ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath) +# We need to specify the path to the node_modules/.bin directory +# The automatic detection of the path doesn't work in all cases, as it could contain an escape sequence. +ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] ||= File.expand_path("../../node_modules/.bin", Pathname.new(__FILE__).realpath) APP_ROOT = File.expand_path("..", __dir__) Dir.chdir(APP_ROOT) do diff --git a/bin/webpacker-dev-server b/bin/webpacker-dev-server index 6629114a..bb735160 100755 --- a/bin/webpacker-dev-server +++ b/bin/webpacker-dev-server @@ -1,16 +1,16 @@ #!/usr/bin/env ruby +require "pathname" +require "bundler/setup" +require "webpacker" +require "webpacker/dev_server_runner" + ENV["RAILS_ENV"] ||= "development" ENV["NODE_ENV"] ||= ENV["RAILS_ENV"] - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require "bundler/setup" - -require "webpacker" -require "webpacker/dev_server_runner" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath) +# We need to specify the path to the node_modules/.bin directory +# The automatic detection of the path doesn't work in all cases, as it could contain an escape sequence. +ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] ||= File.expand_path("../../node_modules/.bin", Pathname.new(__FILE__).realpath) APP_ROOT = File.expand_path("..", __dir__) Dir.chdir(APP_ROOT) do