Getting error when running npm start (ng serve) 'SyntaxError: missing ) after argument list' windows only

Viewed 3163

when doing npm start i get the following error

C:\Users\Me\Desktop\myProject\node_modules\.bin\ng:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at Module._compile (internal/modules/cjs/loader.js:721:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Heres what my package.json is set to

  "scripts": {
    "start": "node --max_old_space_size=8192 node_modules/.bin/ng serve --configuration=dev",
    }

Its odd because when I'm on my same project, but on a mac I can get npm start to work just fine. It must be a windows thing.

Any suggestions?

3 Answers

On Windows, don't use the ng script in the node_modules/.bin directory, but instead use the one in the @angular/cli/bin directory.

"scripts": {
    "start": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve --configuration=dev",
     }

Please compare your code with it...

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/../@angular/cli/bin/ng" "$@"
  ret=$?
else 
  node  "$basedir/../@angular/cli/bin/ng" "$@"
  ret=$?
fi
exit $ret

I was using below configuration in package.json file

"scripts": {
 "test": "node --inspect node_modules/.bin/cross-env API_HOST=url ember serve",
}

The above config work for the Linux machine. But I have a windows machine and during npm run test I got this error.

In my case when I removed node --inspect than its work for me.

 "test": "node_modules/.bin/cross-env API_HOST=url ember serve",
Related