-
Notifications
You must be signed in to change notification settings - Fork 85
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
NoMethodError: undefined method `start_with?' for nil:NilClass #137
Comments
Using the options bellow did the tricky to me. No idea why though ¯\(°_o)/¯
|
@phlcastro my savior you are. |
@phlcastro's solution worked for me as well
|
@phlcastro thx that worked |
@phlcastro That worked thanks! |
|
I encountered this by way of jekyll-assets. All of the sudden, for no apparent reason, my Jekyll site stopped compiling. Instead,
Adding a def error_message(result)
result['error']['message'] +
if result['error']['message'].start_with?("Unexpected token") && !harmony?
". To use ES6 syntax, harmony mode must be enabled with " \
"Uglifier.new(:harmony => true)."
else
""
end
end Based on this, my understanding is that my site stopped building successfully because of an error caused by Uglifier not knowing how to compress an unused declaration. Fun. The fix for me (again, in Jekyll) was to define the following configuration (thanks to the tip from @phlcastro): assets:
compressors:
uglifier:
harmony: true
compress:
unused: false Unfortunately, this is undocumented. I only knew to try this thanks to this commit message. I'm posting this for the benefit of any other jekyll-assets users who encounter this error and are looking for a resolution. |
I am facing the same issue and I have the following gems:
and server has node version v6.16.0 . I also added Kindly let me know what could be causing the issue while precompiling the assets in production. |
I also was benefited by the most accepted comment :D Uglifier.new(harmony: true, compress: { unused: false }) My gem versions:
|
FWIW, this is fixed in latest Uglifier 4.2.0 Gem:
|
it's because, if your javascript contains latest ES8 syntax like |
4.2.0 did not fix the issue. |
uglifier does NOT support ES6 completely, so I switched to "https://github.com/ahorek/terser-ruby". |
As of c8b403b, some of our dependencies are in ES6 or higher. Previously, we had configured webpack to ignore everything in node_modules during it's Babel step because everything we were using was already transformed into more browser-compliant forms of JS, but since we can no longer assume that is true, we need to run everything through Babel so if a dependency uses ES6, we perform our own transformations to browser-compliant JS. This slows things down and seems like it might increase the size of the JS assets. If we don't do this, we end up running a JS file with ES6 syntax through Uglifier during asset precompilation, which gives it indigestion. Uglifier *can* be configured to handle ES6 with `harmony: true`, but trying that led to other problems with the version of Uglifier we're using that may not have been resolved (see lautis/uglifier#137). Note that I tried experimenting with the `exclude` feature in the webpack config so it wouldn't exclude certain directories in node_modules, but it's really hard to figure out exactly what dependency is using some piece of ES6 syntax that causes.
NoMethodError: undefined method `start_with?' for nil:NilClass
My setup:
Error raised during deployment.
Recently I've added @ckeditor/ckeditor5-build-classic npm package which contains ES6 syntax.
Now I'm getting this error.
Here is capistrano log
Reproduction:
The text was updated successfully, but these errors were encountered: