Syntax Error When Attempting to Run 'underscore'
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.
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)
➜ ~ 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.
same here
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)
same
use pjson instead.
Same error. Given the thread it doesn't look like there is a work around.
Another good tool is jq
Just switched to it
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 :(
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.
+1
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.
+1 (10.11.4)