Comments (14)
I just found out what is a solution here: enclose the value in double quotes like this:
npx angular-prerender --parameter-values '\"{\\\":name\\\":[\\\"am e l i a\\\",\\\"o l i v e r\\\"]}\"'
from angular-prerender.
Hi @aristotelos, thanks for bringing this to my attention. I can't reproduce the problem which is why I have the feeling that this could be an incompatibility between macOS and Windows.
Does it work if you use some other type of quotes?
from angular-prerender.
Well, PowerShell has single quotes as its standard escape character, so this seems the best option. I also tried with double quotes like this, but it fails:
PS C:\mydir> npx angular-prerender --parameter-values "'{`":name`":[`"amelia`",`"oliver`"]}'"
Opties:
--version Toon versienummer [booleaans]
--help Toon help [booleaans]
--browser-target specify the target inside your angular.json file which is
used to build the single page app
[string] [standaard: "build"]
[string] [standaard:
"C:\mydir\angular.json"]
--parameter-values specify the parameter values which should be replaced with
the parameter in the routes [string] [standaard: "{}"]
--server-target specify the target inside your angular.json file which is
used to build the server side code
[string] [standaard: "server"]
--verbose, -v set this flag if you prefer more detailed log messages
Unexpected token : in JSON at position 1
Even simple JSON like this fails:
PS C:\mydir> npx angular-prerender --parameter-values '{"foo":"bar"}'
Opties:
--version Toon versienummer [booleaans]
--help Toon help [booleaans]
--browser-target specify the target inside your angular.json file which is
used to build the single page app
[string] [standaard: "build"]
--config specify the path to the angular.json file
[string] [standaard:
"C:\mydir\angular.json"]
--parameter-values specify the parameter values which should be replaced with
the parameter in the routes [string] [standaard: "{}"]
--server-target specify the target inside your angular.json file which is
used to build the server side code
[string] [standaard: "server"]
--verbose, -v set this flag if you prefer more detailed log messages
[booleaans] [standaard: false]
Unexpected token f in JSON at position 1
from angular-prerender.
Thanks for checking again. I believe now that all quotes somehow get lost. I don't know why though.
If you execute JSON.parse('{:name:[amelia,oliver]}')
the error is 'SyntaxError: Unexpected token : in JSON at position 1' and if you execute JSON.parse('{foo:bar}')
the error is 'Unexpected token f in JSON at position 1'. That matches with the error messages that you got.
I improved the error messages in v4.3. It will not help with the problem but it will help to verify my assumption because it logs the values as part of the error that could not be parsed.
Can you please check again with the latest version? Many thanks in advance.
from angular-prerender.
Just a quick follow up. I found this documentation for the AWS CLI. It explains how to escape JSON values for PowerShell.
https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-parameters-quoting-strings.html
Does it work if you escape all quotes with a backslash and run: npx angular-prerender --parameter-values '{\":name\":[\"amelia\",\"oliver\"]}'
?
from angular-prerender.
No, it doesn't work unfortunately. I'll show a couple of commands that I tried so far with their output.
PS>npx angular-prerender --parameter-values '{\":name\":[\"amelia\",\"oliver\"]}'
Please specify valid parameter values. The given value "{:name:[amelia,oliver]}" is invalid.
PS>npx angular-prerender --parameter-values '{":name":["amelia","oliver"]}'
Please specify valid parameter values. The given value "{:name:[amelia,oliver]}" is invalid.
PS>npx angular-prerender --parameter-values "{`":name`":[`"amelia`",`"oliver`"]}"
Please specify valid parameter values. The given value "{:name:[amelia,oliver]}" is invalid.
PS>npx angular-prerender --parameter-values "{':name':['amelia','oliver']}"
Please specify valid parameter values. The given value "{':name':['amelia','oliver']}" is invalid.
PS>npx angular-prerender --parameter-values "{\`"name\`":[\`"amelia\`",\`"oliver\`"]}"
Please specify valid parameter values. The given value "{name:[amelia,oliver]}" is invalid.
PS>npx angular-prerender --parameter-values '{`\"name`\":[`\"amelia`\",`\"oliver`\"]}'
Please specify valid parameter values. The given value "{`name`:[`amelia`,`oliver`]}" is invalid.
PS>npx angular-prerender --parameter-values '{\`"name\`":[\`"amelia\`",\`"oliver\`"]}'
Please specify valid parameter values. The given value "{\`name\`:[\`amelia\`,\`oliver\`]}" is invalid.
I even tried using cmd instead, but also with no success. It seems the "
characters are simply removed.
CMD>npx angular-prerender --parameter-values '{\"name\":[\"amelia\",\"oliver\"]}'
Please specify valid parameter values. The given value "{name:[amelia,oliver]}" is invalid.
from angular-prerender.
It seems like a hopeless attempt but the AWS docs say the cmd prompt should be encapsulated in double quotes. Maybe that's a combination worth trying.
npx angular-prerender --parameter-values "{\":name\":[\"amelia\",\"oliver\"]}"
Does that work?
from angular-prerender.
Tried that too, doesn't work:
CMD>npx angular-prerender --parameter-values "{\"name\":[\"amelia\",\"oliver\"]}"
Please specify valid parameter values. The given value "{name:[amelia,oliver]}" is invalid.
CMD>npx angular-prerender --parameter-values '{^"name^":[^"amelia^",^"oliver^"]}'
Please specify valid parameter values. The given value "{name:[amelia,oliver]}" is invalid.
from angular-prerender.
To be honest I have no idea, what else you could try. But I was thinking about supporting files as well. Maybe that could be a solution which works for you as well. What would you think about something like this?
npx angular-prerender --parameter-values ./my-parameter-values.json
from angular-prerender.
I have found a way! Using an escaped backslash and escaped double quote actually works, in both PowerShell and cmd:
PS>npx angular-prerender --parameter-values '{\\\":name\\\":[\\\"amelia\\\",\\\"oliver\\\"]}'
It may have to do with this issue.
from angular-prerender.
The next question is: how do I escape a space inside a parameter value...
from angular-prerender.
Wow thanks for the follow up. I will update the README once we resolved this issue.
Normally I would say don't escape whitespace at all, but I guess that doesn't work for you, right?
npx angular-prerender --parameter-values '{\\\":name\\\":[\\\"a m e l i a\\\",\\\"o l i v e r\\\"]}'
from angular-prerender.
Well, that doesn't work, it ends up with:
PS>npx angular-prerender --parameter-values '{\\\":name\\\":[\\\"a m e l i a\\\",\\\"o l i v e r\\\"]}'
Please specify valid parameter values. The given value "{":name":["a" is invalid.
I again tried one, two or three or four slashes, but that doesn't work... Because it seems to be a PowerShell or general npx issue I will close it here.
from angular-prerender.
Wow, I'm glad you found a solution. I added a small paragraph to the readme to mention that escaping might be an issue.
from angular-prerender.
Related Issues (20)
- An in-range update of husky is breaking the build 🚨 HOT 2
- An in-range update of guess-parser is breaking the build 🚨 HOT 1
- An in-range update of @angular-devkit/core is breaking the build 🚨 HOT 1
- "Multiple root routing modules" error when one lazy loading module is loaded from another HOT 6
- Improve parameter-values HOT 7
- An in-range update of eslint-config-holy-grail is breaking the build 🚨 HOT 1
- Atob is not defined HOT 4
- Add changelog HOT 1
- Support request: possible to deploy as cloud function? HOT 5
- Feature request: add support for `--exclude-routes *` HOT 9
- Please install ts-evaluator instead HOT 5
- duplicate app state in prerendered page HOT 8
- Feature Request: option for prerendering routes from a txt file --include-routes-file HOT 1
- Not picking up the routes array in angular.json HOT 9
- An in-range update of tsconfig-holy-grail is breaking the build 🚨 HOT 1
- Basic project example seems to be missing a step HOT 4
- How to use this plugin with https://prerender.io/ HOT 2
- An in-range update of core-js is breaking the build 🚨 HOT 1
- angular-prerender creates huge HTML file with CSS and source map HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-prerender.