How to run TopoJSON on Mac? - node.js

I need to bind a CSV file to topojson. I installed Node js with brew.
I can successfully run the command npm install -g topojson but when I put in which topojson, it doesn't return any file path.
I checked to confirm I have the command line tools installed and I do.
My command to bind the CSV returns -bash: topojson: command not found even though the npm install -g topojson command runs smoothly.

topojson package installs five executables: geo2topo, toposimplify, topomerge, topo2geo, topoquantize.
Getting command not found for trying to execute topojson is the normal response: indeed, such an executable does not exist.

Related

Trying to install less on Ubuntu 16.04

As I wrote up there I'm trying to install less on Ubuntu. I'm using Xampp as localhost, but from what I've read seems that it doesn't matter. However, after I've installed node.js from nodejs.org, I went to lesscss.org and I followed the instructions.
When I type this command on the terminal
lessc styles.less
I get the following error
lessc: ENOENT: no such file or directory, open '/path/to/cwd/styles.less'
where the path corresponds to my actual path but there isn't any styles.less file of course. I also tried to create a blank one and retry but nothing. What should I do ?
You probably need to install less using npm install -g less. lessc should be available as /usr/bin/lessc.
Also, make sure /usr/bin is on your path by running echo $PATH.
EDIT
I just noticed you were able to run it. You need to create some .less files and run lessc <FILENAME>. The output will be printed out to the screen but you can specify a destination file as well, lessc <SOURCE> <DESTINATION>. See command line usage I recommend using a build tool such as gulp or webpack.
STEPS TO INSTALL LESS IN UBUNTU 16.04
Open Terminal.
Check availability of npm. Write "npm -v", here -v means version.
If there is npm by default in your system then it will show you the version of that npm. If there is no npm installed in your system then it will ask you to install the npm.
To install npm in your ubuntu. Write "sudo apt install npm".
Now you have to install the less library. So, to install less. Write 2 commands accordingly:-
(i) sudo apt install less
(ii) sudo apt install node-less

Node command not found

I'm trying to install avrgirl-arduino using the command sudo npm install avrgirl-arduino. When I try running the command avrgirl-arduino list I get an error saying -bash: avrgirl-arduino: command not found. I ran npm init before running the first command and it still doesn't work.
You may want to install your package globally :
npm install -g avrgirl-arduino
This way you can use command line tool package (like grunt)

Cannot get "npm install -g" to work on any packages (AppData/Roaming/npm always empty)

Running nodejs on Windows 7 Enterprise at work.
Whenever I install a node_module that needs -g access, from experience I know it's supposed to create a *.bat file in %AppData$/Roaming/npm, but for some reason it no longer does that.
For example, I will run npm install gulp -g, console looks like it installed correctly, but the files will not be in the AppData folder. And if I try running a gulp command, I get error sh.exe": gulp: command not found.
If I run the npm install gulp -g command in Console As Administrator, it installs the files into the %AppData% folder of the administrator (instead of the regular user). So if I run the gulp command through my non-administrator user, I still get error sh.exe": gulp: command not found.
Any ideas?
Found solution:
(1) Upon running the command: npm config get prefix, output is C:\Program Files (x86)\Git\local. No idea why it was set to this, as it's not the default.
But I changed it using: npm config set prefix "$APPDATA\npm".
Now when I install a --g module, ie. npm install gulp -g, it installs into this desirable directory, no longer throwing EPERM and ENOENT errors.
(2) Still need to add a PATH entry for the npm folder. The command export PATH=$PATH:/c/Users/{YOUR_USERNAME}/AppData/Roaming/npm works temporarily, but if you close console and open it again, might not be saved (if you are not an administrator).
But you can also use echo 'export PATH=$PATH:/c/Users/{YOUR_USERNAME}/AppData/Roaming/npm' >> ~/.bash_profile, which will create a .bash_profile file, which is run each time as your console is opened. So from this point, it should automatically add the required PATH entry.
I also faced this same issue.
After installing node.js(https://nodejs.org/en/download/) npm folder(in appdata folder) remain empty.
so, at this stage if you try to build/run angular project(ng build/ng serve), it will give error as:
The term 'ng' is not recognized as the name of a cmdlet, function, script file, or operable program.
So, for fixing this issue install angular globally in your project with following command:
npm install -g #angular/cli
Now, there would be data in npm folder(node modules etc.) and ng command will run now.

How to run TopoJSON?

I need to convert a geojson file to topojson and possibly simplify the topojson file. I've managed to install Node.js and the topojson package. But I have no idea how to run topojson.
The wiki lists a bunch of command line options, but where do I run those commands? I've tried running them both in the command prompt and the node shell. Node, GDAL, ogr2ogr and TopoJSON are all new concepts for me, so I'm a bit confused and overwhelmed.
I'm running on Windows by the way.
topojson executable is now changed to geo2topo
Installation steps remain the same, just like topojson
To create a topo json file from geo json file, geo2topo -o topo-output.json geo-input.json
One way to obtain geo-input.json is from gdal which takes a shape file as input and outputs geojson. gdal can be installed via home brew using brew install gdal
this should work fine on windows too
install nodejs http://nodejs.org/
install npm https://npmjs.org/doc/README.html
run npm install -g topojson in your command prompt
use the command prompt to cd to the geojson file
run topojson -o myNewTopojsonFile.json myOldGeojsonFile.json
origin https://gis.stackexchange.com/questions/45138/convert-geojson-to-topojson
I had the same issue on Ubuntu 14.04.
I found that my node.js executable is called nodejs instead of node.
I opened the topojson script (usr/bin/topojson) and found that it was trying to run topojson with a node executable called node.
#!/usr/bin/env node
I edited this file so that it runs with nodejs instead
#!/usr/bin/env nodejs
and now it works fine for me.
Hope this helps someone else.
It has been changed to geo2topo
1) Run
sudo npm install -g geo2topo
2) check if it returns the path
which geo2topo
It should give the path /usr/bin/geo2topo
3) Use it to convert your geojson file
geo2topo -o output.json input.json

node npm local install puts files into ~/node_modules

When I install a package using npm install command, it installs the files into ~/node_modules. When I run the package, I get command not found error.
How do I install it into a folder where I want to call the package?
npm install <name_of_package> -g
This will install the package globally. If the program is in your PATH, then you should be able to run it just like any other program.
For example:
npm install nodemon -g
then run nodemon from the command prompt, and it should work
If you don't want to install it globally, the right answer is the last comment in the checked answer:
Simply add ./node_modules/.bin to your PATH, and all the commands installed locally by npm will be available. – H_I Dec 24 '12 at 9:54
You can add it to your path in your .bashrc file using the command:
export PATH="$PATH:/home/login/node_modules/.bin"
Reload your .bashrc using:
source .bashrc

Resources