Git Product home page Git Product logo

Comments (11)

trentm avatar trentm commented on July 28, 2024

@craigwblake I don't have enough to go on here. How did you install this? which json Can you show me the content of the json script file that is running?

from json.

craigwblake avatar craigwblake commented on July 28, 2024

Sure, I'll share what I can. I run "apt-get install node" to install node then ran "npm install -g jsontool" per the instructions on the main page. That all completed without error, and it installed the json command in "/usr/local/bin/json"

Here is the content of the file in that location:

#!/usr/bin/env node
//
// json -- a 'json' command for massaging JSON on the command line
//
// See <https://github.com/trentm/json>.
//

var VERSION = "6.0.0";

var p = console.warn;
var util = require('util');
var assert = require('assert');

... most of file ellided because have enough here to confirm this is *my* json tool :) ...

    };
  }

  main(process.argv);
}

from json.

trentm avatar trentm commented on July 28, 2024

@craigwblake Thanks. Okay, what is the output of:

which node

`which node` --version

`which node` /usr/local/bin/json --version

I've not seen that behaviour (calling json --version exiting showing nothing). I've also never used the apt-provided node on Ubuntu.

from json.

craigwblake avatar craigwblake commented on July 28, 2024

Well I ran that and it didn't work I looked into and found out that on Ubuntu the Node.js binary is installed as 'nodejs'.

That certainly explains why it wasn't working, but it's definitely not obvious from the lack of output. Maybe it's worth checking for 'nodejs' as the executable if 'node' fails in your script?

from json.

craigwblake avatar craigwblake commented on July 28, 2024

Also, for reference there is a different 'node' binary on Ubuntu (which is why nodejs could not use the name) which when run outputs nothing. Quite an annoying coincidence that made the problem non-obvious.

from json.

trentm avatar trentm commented on July 28, 2024

What?! That's crazy. I don't know a reasonable way to deal with that on json's end. There must be many node.js-based command line tools that have this same issue.

A little bit of searching turned this up: http://askubuntu.com/questions/235655/node-js-conflicts-sbin-node-vs-usr-bin-node Specifically:

sudo apt-get --purge remove node
sudo apt-get --purge remove nodejs
sudo apt-get install nodejs

# Confirm it worked
node --version       # v0.10.13
ls -la `which node`  # ... /usr/bin/node -> /etc/alternatives/node

Is that a reasonable workaround for you? I'm not familiar with current and past Ubuntu node.js packaging naming.

from json.

craigwblake avatar craigwblake commented on July 28, 2024

I tried but it still didn't link the 'nodejs' binary to 'node'. Oh well, I manually linked it so it works now. Perhaps it would be sufficient for a warning for Ubuntu users on your installation instructions?

from json.

trentm avatar trentm commented on July 28, 2024

@craigwblake I got a response from @isaacs:

The answer is that this is a known bug in debian-stable. He should either: a) install from source, b) install from the binary tarballs on http://nodejs.org/ or c) use chrislea's PPA https://launchpad.net/~chris-lea/+archive/node.js/

it is my understanding that Debian is changing this moving forward.
so future versions will have the "nodejs" package install a binary called "node", and have it conflict with the "ham-node" package

from json.

trentm avatar trentm commented on July 28, 2024

README.md warning added in the install section. Thanks!

from json.

stevebest avatar stevebest commented on July 28, 2024

Instead of #!/usr/bin/env node, try this

#!/usr/bin/env sh
':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@"

Say whaaaat?

It's a polyglot script. sh sees it as a shell script that tries to exec itself using either nodejs or node; node sees it as a no-op and executes everything below. Everyone is happy!

Credit goes to guys on stackexchange.

from json.

stevebest avatar stevebest commented on July 28, 2024

See #74.

The warnings in docs and install scripts are probably no longer required with this hack and could be removed.

from json.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.