Reputation: 1344
On windows, at the "Node.js command prompt" (as opened from the Start Menu), I can run the following:
highcharts-export-server -infile "C:\Users\bailis02\Desktop\R Export\hc.json"
--type svg -outfile "C:\Users\bailis02\Desktop\R Export\hc.svg"
highcharts-export-server was installed via npm with the -g option as outlined at: https://github.com/highcharts/node-export-server/blob/master/README.md
What is the best way of running the same, but directly from the standard windows command line? I have found the following work from the windows command line:
"C:\Users\bailis02\AppData\Roaming\npm\highcharts-export-server.cmd"
-infile "hc.json" --type svg -outfile "hc.svg"
"C:\Program Files\nodejs\node.exe" "C:\Users\bailis02\AppData\Roaming\npm\
node_modules\highcharts-export-server\bin\cli.js"
-infile "hc.json" --type svg -outfile "hc.svg"
Is there a smarter way of doing this, e.g. where I can just specify "highcharts-export-server" without having to specify a path into AppData\Roaming?
Upvotes: 0
Views: 168
Reputation: 17942
If you add C:\Program Files\nodejs
to your PATH
environment variable, you could shorten that to
node "C:\Users\bailis02\AppData\Roaming\npm\node_modules\highcharts-export-server\bin\cli.js" -infile "hc.json" --type svg -outfile "hc.svg"
If you use special folder lookups:
node "%APPDATA%\npm\node_modules\highcharts-export-server\bin\cli.js" -infile "hc.json" --type svg -outfile "hc.svg"
If you do this often it could justify a script, something like this (note this is thrown together and untested):
import exporter from 'highcharts-export-server';
exporter.initPool();
exporter.export({
infile: process.env.argv[2],
type: process.env.argv[3],
outfile: process.env.argv[4]
});
then you could use it like so:
node export.js hc.json svg hc.svg
And you can always tweak the arguments etc to suit your use-case. The highcharts-export-server documentation lists all the goodies you can use.
Upvotes: 1