-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw an exception if NODE_ENV is not set when running webpack #583
Conversation
On a brand new install, if NODE_ENV is not already set, then running `bin/webpack` will fail with an obscure error message: path: resolve('public', settings.public_output_path), ^ TypeError: Cannot read property 'public_output_path' of undefined at Object.<anonymous> (.../config/webpack/configuration.js:26:35) Since someone will never be able to run webpack without NODE_ENV set, it makes sense to give the developer a message to help them debug.
Throw an exception if NODE_ENV is not set when running webpack
@soundasleep Thanks for this but we already set this inside binstub - https://github.com/rails/webpacker/blob/master/lib/install/bin/webpack.tt#L10 |
I realised that later... I was having issues with yarn not playing nicely on Windows (it was trying to execute using the wrong path separators), so was having to run webpack manually, which caused this. Happy to close :) |
@soundasleep Could you please help me debug that? It seems that many people are having same problem on windows but I don't have access to a windows machine. |
Absolutely! I'd be happy to help, what would you like me to do? Here's some of my history: You can't run something with a forward slash in Windows:
So, I used backslash. But because it isn't a .bat or .cmd file, Windows doesn't read the first line of the script as the interpreter to use:
So I then started passing along the script to Ruby. But then the path separator thing started occurring:
What I've done, in the meantime as a workaround, is the following in my # ... etc
newenv = { "NODE_PATH" => NODE_MODULES_PATH.shellescape }
if Gem.win_platform?
cmdline = ["#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG] + ARGV
else
cmdline = ["yarn", "run", "webpack", "--", "--config", WEBPACK_CONFIG] + ARGV
end
Dir.chdir(APP_PATH) do
exec newenv, *cmdline
end And now if I go It might be an issue with Yarn but I'm not confident. |
Thank you so much. This is great 👍 🍰 Perhaps, you wanna make a PR with your solution until yarn is fixed. I saw many issues raised with same problem. Does the solution works with foreman too? |
I guess we will also need to document the README to add |
- Bypass `yarn run` when running on Windows; instead, we can go directly to `node_modules/.bin/` - Create batch scripts so users don't need to type in `ruby bin/webpack` manually See discussion on rails#583
How's this? ^_^ #584 |
closing in favour of #584 |
* Workarounds for Yarn not playing nicely on Windows - Bypass `yarn run` when running on Windows; instead, we can go directly to `node_modules/.bin/` - Create batch scripts so users don't need to type in `ruby bin/webpack` manually See discussion on #583 * Update Changelog and README for Webpacker on Windows Do not generate batch files when installing
* Workarounds for Yarn not playing nicely on Windows - Bypass `yarn run` when running on Windows; instead, we can go directly to `node_modules/.bin/` - Create batch scripts so users don't need to type in `ruby bin/webpack` manually See discussion on rails/webpacker#583 * Update Changelog and README for Webpacker on Windows Do not generate batch files when installing
* Workarounds for Yarn not playing nicely on Windows - Bypass `yarn run` when running on Windows; instead, we can go directly to `node_modules/.bin/` - Create batch scripts so users don't need to type in `ruby bin/webpack` manually See discussion on rails/webpacker#583 * Update Changelog and README for Webpacker on Windows Do not generate batch files when installing
* Workarounds for Yarn not playing nicely on Windows - Bypass `yarn run` when running on Windows; instead, we can go directly to `node_modules/.bin/` - Create batch scripts so users don't need to type in `ruby bin/webpack` manually See discussion on rails/webpacker#583 * Update Changelog and README for Webpacker on Windows Do not generate batch files when installing
On a brand new install, if NODE_ENV is not already set, then
running
bin/webpack
will fail with an obscure error message:Since someone will never be able to run webpack without NODE_ENV set,
it makes sense to give the developer a message to help them debug.