Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") SyntaxError: missing ) after argument list #677

Closed
ghost opened this issue Aug 11, 2016 · 9 comments

Comments

@ghost
Copy link

ghost commented Aug 11, 2016

I have a super simple Nodejs ES6 app. Not using Babel, not required.

On my Mac, the app runs, all tests run, and istanbul coverage works perfect.

On my Windows 10, the app runs, all tests run, but I get the below error when trying to use coverage.

Mac node -v v6.2.2
Windows node -v v6.3.1

Apologies, but I have no idea where to start. I've searched the web, one other person reported a similar problem on Windows here: npm/cmd-shim#17 but I can't be sure this is the exact same root cause, I don't have the deep expertise.

Thank you in advance for any help in getting this working on Windows.

This is my command line:

node ./node_modules/.bin/istanbul cover ./node_modules/.bin/mocha

  "devDependencies": {
    "chai": "^3.5.0",
    "istanbul": "^0.4.4",
    "mocha": "^3.0.2",
    "sinon": "^1.17.5",
    "sinon-chai": "^2.8.0"
  }

Error message:

\\Mac\Home\Documents\nodejs-es6-mocha\node_modules\.bin\istanbul:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^
SyntaxError: missing ) after argument list
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:513:28)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)
    at bootstrap_node.js:467:3

Thank you,

Karl

@copenhas
Copy link

I added a comment on npm/cmd-shim#17 which I believe will solve the issue. For those who come here please refer to Usage on Windows section in the Istanbul readme.

@ghost
Copy link
Author

ghost commented Aug 11, 2016

@copenhas thank you very much. I'll test tonight, confirm, and close this.

@ghost
Copy link
Author

ghost commented Aug 12, 2016

@copenhas bingo!

This works for mocha: ./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha

Thank you for your outstanding support and very quick response.

Best to you,

Karl

@henry-luo
Copy link

For those who uses Tape, the command should be :
istanbul cover node_modules/tape/bin/tape test_file.js

@burdiuz
Copy link

burdiuz commented Oct 12, 2017

Just got the same error with tsc calling other module on windows 10, solved it by removing all shell(the ones without extension) files from node_modules/.bin/ folder -- it started to use *.cmd files.

@akagrawat
Copy link

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

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

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

This solution works for Windows machine

@sandervalstar
Copy link

I'd recommend using npx instead, you can run any executable under the node_modules/.bin directory with:
npx the-executable

s-oram added a commit to foyerlive/fl-cli that referenced this issue Nov 11, 2020
I'm attempting to build the [playground](https://github.com/foyerlive/playground) 
project on Windows but have run into an error. 

Running `npm run build` in the Playground project results in: 
```
D:\dev-ie\auspost-kiosk\playground\node_modules\.bin\webpack:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^
SyntaxError: missing ) after argument list
```

The build fails after this error. It appears to be a 
common error on Windows. 

gotwarlost/istanbul#677
jestjs/jest#4751

There might be a few potential solutions. 

This blog post suggested changing how Webpack is called. 
https://www.programmersought.com/article/49215661254/

Quote:
> The first type of packaging command is ./node_modules/.bin/webpack, 
> you can see that all the shell commands in the .bin directory are .cmd;
> 
> The second type of packaging command is ./node_modules/webpack/bin/webpack, 
> the last webpack is actually a js file, of course it supports node, 
> which also reflects the flexibility and omnipotence of the js language.
s-oram added a commit to foyerlive/fl-cli that referenced this issue Nov 12, 2020
I'm attempting to build the [playground](https://github.com/foyerlive/playground) 
project on Windows but have run into an error. 

Running `npm run build` in the Playground project results in: 
```
D:\dev-ie\auspost-kiosk\playground\node_modules\.bin\webpack:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^
SyntaxError: missing ) after argument list
```

The build fails after this error. It appears to be a 
common error on Windows. 

gotwarlost/istanbul#677
jestjs/jest#4751

There might be a few potential solutions. 

This blog post suggested changing how Webpack is called. 
https://www.programmersought.com/article/49215661254/

Quote:
> The first type of packaging command is ./node_modules/.bin/webpack, 
> you can see that all the shell commands in the .bin directory are .cmd;
> 
> The second type of packaging command is ./node_modules/webpack/bin/webpack, 
> the last webpack is actually a js file, of course it supports node, 
> which also reflects the flexibility and omnipotence of the js language.
@aditodkar
Copy link

aditodkar commented Feb 5, 2021

Hi all, I am using a windows laptop and I am trying to debug mocha test files in nodejs application using vscode but I am getting this error same error as above when I try to debug the individual spec file in vscode any idea how can it be fixed? Do I need to make any changes in launch.json or package.json file?

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^
SyntaxError: missing ) after argument list

@farshad-vgr
Copy link

Hi all, I am using a windows laptop and I am trying to debug mocha test files in nodejs application using vscode but I am getting this error same error as above when I try to debug the individual spec file in vscode any idea how can it be fixed? Do I need to make any changes in launch.json or package.json file?

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^
SyntaxError: missing ) after argument list

Just change path name:
for example instead "./node_modules/.bin/webpack" use this: "./node_modules/webpack/bin/webpack.js"

AllanOricil added a commit to AllanOricil/nrg that referenced this issue Sep 29, 2024
This fixes the following error that happens when start node-red in windows and bash

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") SyntaxError: missing ) after argument list

gotwarlost/istanbul#677
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants