underscore-cli icon indicating copy to clipboard operation
underscore-cli copied to clipboard

Syntax Error When Attempting to Run 'underscore'

Open Stunner opened this issue 9 years ago • 13 comments

Installed this script following instructions from the README and am seeing the following error:

$ underscore
/usr/local/Cellar/nvm/0.30.1/versions/io.js/v1.2.0/lib/node_modules/underscore-cli/bin/underscore:69
        .join(' ');
         ^
TypeError: undefined is not a function
    at /usr/local/Cellar/nvm/0.30.1/versions/io.js/v1.2.0/lib/node_modules/underscore-cli/bin/underscore:69:10
    at Array.map (native)
    at Command.commandHelp (/usr/local/Cellar/nvm/0.30.1/versions/io.js/v1.2.0/lib/node_modules/underscore-cli/bin/underscore:62:6)
    at Command.helpInformation (/usr/local/Cellar/nvm/0.30.1/versions/io.js/v1.2.0/lib/node_modules/underscore-cli/bin/underscore:193:26)
    at printHelp (/usr/local/Cellar/nvm/0.30.1/versions/io.js/v1.2.0/lib/node_modules/underscore-cli/bin/underscore:246:25)
    at main (/usr/local/Cellar/nvm/0.30.1/versions/io.js/v1.2.0/lib/node_modules/underscore-cli/bin/underscore:792:5)
    at Object.<anonymous> (/usr/local/Cellar/nvm/0.30.1/versions/io.js/v1.2.0/lib/node_modules/underscore-cli/bin/underscore:1024:3)
    at Module._compile (module.js:446:26)
    at Object.Module._extensions..js (module.js:464:10)
    at Module.load (module.js:341:32)

Please note, I'm using Mac OS X version 10.10.5.

Stunner avatar Feb 16 '16 12:02 Stunner

same here:

underscore help                                       
Unknown command: 'help'
/usr/lib/node_modules/underscore-cli/bin/underscore:69
        .join(' ');
         ^

TypeError: _(...).map(...).join is not a function
    at /usr/lib/node_modules/underscore-cli/bin/underscore:69:10
    at Array.map (native)
    at Command.commandHelp (/usr/lib/node_modules/underscore-cli/bin/underscore:62:6)
    at Command.helpInformation (/usr/lib/node_modules/underscore-cli/bin/underscore:193:26)
    at printHelp (/usr/lib/node_modules/underscore-cli/bin/underscore:243:27)
    at Command.<anonymous> (/usr/lib/node_modules/underscore-cli/bin/underscore:802:7)
    at emitOne (events.js:77:13)
    at Command.emit (events.js:169:7)
    at Command.parseArgs (/usr/lib/node_modules/underscore-cli/node_modules/commander/lib/commander.js:408:12)
    at Command.parse (/usr/lib/node_modules/underscore-cli/node_modules/commander/lib/commander.js:352:15)

tugberkugurlu avatar Feb 20 '16 21:02 tugberkugurlu

➜ ~ git:(master) ✗ underscore /home/lk/.jumbo/lib/node_modules/underscore-cli/bin/underscore:69 .join(' '); ^ TypeError: undefined is not a function at /home/lk/.jumbo/lib/node_modules/underscore-cli/bin/underscore:69:10 at Array.map (native) at Command.commandHelp (/home/lk/.jumbo/lib/node_modules/underscore-cli/bin/underscore:62:6) at Command.helpInformation (/home/lk/.jumbo/lib/node_modules/underscore-cli/bin/underscore:191:26) at printHelp (/home/lk/.jumbo/lib/node_modules/underscore-cli/bin/underscore:244:25) at main (/home/lk/.jumbo/lib/node_modules/underscore-cli/bin/underscore:790:5) at Object. (/home/lk/.jumbo/lib/node_modules/underscore-cli/bin/underscore:1022:3) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32)

jinleileiking avatar Mar 02 '16 09:03 jinleileiking

same here

f3lang avatar Mar 04 '16 10:03 f3lang

same here

>>> underscore -h
ERROR with '0': TypeError: cmd.match is not a function
    at /usr/local/lib/node_modules/underscore-cli/bin/underscore:97:21
    at String.replace (native)
    at Function.module.exports (/usr/local/lib/node_modules/underscore-cli/node_modules/underscore.string/map.js:8:14)
    at /usr/local/lib/node_modules/underscore-cli/bin/underscore:95:14
    at String.replace (native)
    at Function.module.exports (/usr/local/lib/node_modules/underscore-cli/node_modules/underscore.string/map.js:8:14)
    at Command.examplesHelp (/usr/local/lib/node_modules/underscore-cli/bin/underscore:88:12)
    at Command.helpInformation (/usr/local/lib/node_modules/underscore-cli/bin/underscore:207:26)
    at Command.outputHelp (/usr/local/lib/node_modules/underscore-cli/node_modules/commander/lib/commander.js:994:29)
    at outputHelpIfNecessary (/usr/local/lib/node_modules/underscore-cli/node_modules/commander/lib/commander.js:1061:11)

ghost avatar Mar 08 '16 14:03 ghost

same

maqic avatar Mar 09 '16 02:03 maqic

use pjson instead.

jinleileiking avatar Mar 09 '16 08:03 jinleileiking

Same error. Given the thread it doesn't look like there is a work around.

carljokl avatar Mar 09 '16 11:03 carljokl

Another good tool is jq

Just switched to it

ghost avatar Mar 09 '16 12:03 ghost

Does any of these alternatives support the kind of smart pretty printing underscore-cli had?

I mean, dumb is like this:

$ echo '[[[["This is a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long text" ]]]]' |  python -mjson.tool
[
    [
        [
            [
                "This is a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long text"
            ]
        ]
    ]
]
$ echo '[[[[1]]]]' | python -mjson.tool
[
    [
        [
            [
                1
            ]
        ]
    ]
]

Smart is like this:

 echo '[[[["This is a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long text" ]]]]' | underscore print       
[
  [
    [
      [
        "This is a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long text"
      ]
    ]
  ]
]
$ echo '[[[[1]]]]' | underscore print  
[[[[1]]]]

It's a killer feature when you have to dig through a lenghty JSON data by eye.


Edit: yeah I checked, both pjson and jq are dumb :(

csabahenk avatar Mar 09 '16 12:03 csabahenk

By the way, I have a working installation with these deps deployed:

/home/csaba/node/src/underscore-cli $ npm list
[email protected] /home/csaba/node/src/underscore-cli
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │   ├── [email protected]
│ │   └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

So the fix could be to enforce these exact versions.

csabahenk avatar Mar 09 '16 14:03 csabahenk

+1

rubycut avatar Mar 10 '16 11:03 rubycut

I also get "TypeError: _(...).map(...).join is not a function" MacOs 10.11.12 (El Capitan)

$ underscore /usr/local/lib/node_modules/underscore-cli/bin/underscore:69 .join(' '); ^

TypeError: _(...).map(...).join is not a function at /usr/local/lib/node_modules/underscore-cli/bin/underscore:69:10 at Array.map (native) at Command.commandHelp (/usr/local/lib/node_modules/underscore-cli/bin/underscore:62:6) at Command.helpInformation (/usr/local/lib/node_modules/underscore-cli/bin/underscore:193:26) at printHelp (/usr/local/lib/node_modules/underscore-cli/bin/underscore:246:25) at main (/usr/local/lib/node_modules/underscore-cli/bin/underscore:792:5) at Object. (/usr/local/lib/node_modules/underscore-cli/bin/underscore:1024:3) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32)

smartifier-reilly avatar Mar 15 '16 08:03 smartifier-reilly

+1 (10.11.4)

brianspolarich avatar Apr 12 '16 21:04 brianspolarich