Thursday, 16 March 2017

npm link causes javascript syntax errors

I'm trying to set up a simple CLI with node. When I run npm link and try my command, I get syntax errors logged to the console for perfectly valid JS.

Code

Command Line

$ holla

Output:

/usr/local/bin/holla: line 1: syntax error near unexpected token `'hello''
/usr/local/bin/holla: line 1: `console.log('hello')'

Here is my package.json:

{
  "name": "npm-cli-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "bin": {
    "holla": "index.js"
  }
}

And here is my index.js:

console.log('hello')

Some extra context

If it helps:

# $PATH variable
/Users/stuartpearman/.rbenv/shims:/Users/stuartpearman/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

# npm global packages
/usr/local/lib/node_modules



via Stuart Pearman

No comments:

Post a Comment