path.startsWith is not a function
Expected behavior
Server started using stencil start should serve the local theme
Actual behavior
Nothing renders on the browser and an error is output on the terminal
path.startsWith is not a function
Steps to reproduce behavior
Execute stencil start -o in the terminal in the theme directory.
The theme preview works fine for [email protected], error occurs in 3.0.3 and 3.2.0 that I have tried.
Edit
The preview works if you change the template engine from Handlebars version 4 to Handlebars version 3.
"template_engine": "handlebars_v4" -> "template_engine": "handlebars_v3"
Doesn't seem like a solution.
Do you have any handlebars cdn and concat helpers being used together in your stencil theme? I had this issue and was able to resolve it by updating all of my cdn helpers that also use concat. The concat helper creates a SafeString object and it looks like the cdn helper in handlebars_v4 doesn't like it.
Example:
-
add-payment-method.html in the cornerstone theme has an example of this
cdn/concatcombination.
<img src="{{cdn (concat (concat 'img/payment-methods/' brand) '.svg')}}">
The cdn call in the example above is trying to use a SafeString object as the url:
SafeString { string: 'img/payment-methods/visa.svg' }
I was able to fix this by wrapping the concat helpers with a get helper:
{{cdn (get 'string' (concat (concat 'img/payment-methods/' brand) '.svg'))}}
Do you have any handlebars
cdnandconcathelpers being used together in your stencil theme? I had this issue and was able to resolve it by updating all of mycdnhelpers that also useconcat. Theconcathelper creates a SafeString object and it looks like thecdnhelper in handlebars_v4 doesn't like it.
There are a bunch of such usages in the theme. All of them are in the customizations. I'll make the updates and see if it works for me as well.
This is crazy random to me though. Is there any v3 - v4 migration guide?
@ZackEnders an update. I removed all the instances of the cdn and concat helpers and replaced with what you suggested, still getting the error.
Are there any other things that v4 doesn't like?
It seems like the issue is related to the @bigcommerce/stencil-paper package, specifically version ^3.0.0-rc.30 which comes with the cli by default. I manually switched that to 3.0.0-rc.29 and it seems to work for now, but I haven't done rigorous testing so I don't know what else will break.
Hi @dmaurya-gea! Where you able to proceed with your issue?
If no, could you help me reproducing it by providing some information about your theme? Which theme and version are you using?
Hi @dmaurya-gea! Where you able to proceed with your issue?
If no, could you help me reproducing it by providing some information about your theme? Which theme and version are you using?
Hi @jairo-bc. No the issue was not resolved.
I had to make do with changing the handlebars engine to v3 during local preview, and change it to v4 before push.
I tried it with different versions, all versions 3.x.x had this problem. Not with the latest 2.x.x
@dmaurya-gea Are you on the custom theme? Or is it cornerstone?