open-cli-tools / concurrently

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.
https://www.npmjs.com/package/concurrently
MIT License
7.11k stars 231 forks source link

Concurrently is removing the last character of my command #118

Closed derickkemp closed 6 years ago

derickkemp commented 7 years ago

My project uses concurrently to run server-lite and webpack, my package.json looks as follows.

{
  "name": "my-app",
  "version": "1.0.0",
  "description": "A fancy new app",
  "main": "js/app.bundle.js",
  "scripts": {
    "build": "webpack",
    "server": "concurrently 'lite-server -c bs-config.json' 'webpack'",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://example.com/project/project"
  },
  "keywords": [
    "storage"
  ],
  "license": "SEE LICENSE IN LICENSE.md",
  "private": true,
  "dependencies": {
    "@uirouter/angularjs": "^1.0.5",
    "angular": "^1.6.5",
    "webpack": "^3.3.0"
  },
  "devDependencies": {
    "babel-core": "^6.25.0",
    "babel-loader": "^7.1.1",
    "babel-preset-es2015": "^6.24.1",
    "concurrently": "^3.5.0",
    "html-loader": "^0.4.5",
    "lite-server": "^2.3.0"
  }
}

When I call npm run server on Fedora everything works as expected, when I try the same thing on Windows, I get the following error.

> my-app@1.0.0 server C:\Users\\Documents\src\my-app\static
> concurrently 'lite-server -c bs-config.json' 'webpack'

[0] 'lite-serve' is not recognized as an internal or external command,
[0] operable program or batch file.
[0] lite-serve exited with code 1
[1]
[1] Webpack is watching the files…

I noticed it's removing the "r" from "lite-server", so I tried changing the script line to

{
...
  "scripts": {
    "build": "webpack",
    "server": "concurrently 'lite-serverx -c bs-config.json' 'webpack'",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
...
}

and the it worked perfectly.

> my-app@1.0.0 server C:\Users\\Documents\src\my-app\static
> concurrently 'lite-serverx -c bs-config.json' 'webpack'

[0] ** browser-sync config **
[0] { injectChanges: false,
[0]   files: [ './**/*.{html,htm,css,js}' ],
[0]   watchOptions: { ignored: 'node_modules' },
[0]   server: { baseDir: './', middleware: [ [Function], [Function] ] },
[0]   port: 8080 }
[1]
[1] Webpack is watching the files…

So it seems that concurrently is removing the last character from the command in windows.

gustavohenke commented 7 years ago

Hi @derickkemp, thanks for letting us know. I'll check such behaviour in a Windows machine as soon as possible and post any updates here.

filipesilva commented 7 years ago

@derickkemp can you try using escaped double quotes? I've had some trouble with that in the past as well, single quotes aren't truly supported cross platform in npm scripts:

"server": "concurrently \"lite-server -c bs-config.json\" \"webpack\"",
derickkemp commented 7 years ago

Hi @filipesilva.

I'll give it a spin tonight.

gustavohenke commented 7 years ago

@derickkemp - have you got any news? Unfortunately I haven't organised my time to test this in a VM :(

derickkemp commented 7 years ago

@gustavohenke sorry not yet.

I haven't touched my windows box in weeks. I'll set a reminder.

harrymitchinson commented 7 years ago

I was experiencing this issue on Windows today but haven't done any real investigation into it.

package.json

"scripts": {
    "start": "concurrently \"npm run lint\" \"webpack --watch\" \"npm run serve\"",
    "build": "npm run lint && webpack",
    "serve": "nodemon --watch dist/index.js",
    "test": "jest --forceExit",
    "lint": "tslint -c tslint.json -p tsconfig.json",
    "debug": "npm run build && node --debug-brk=3000 dist/index.js"
}

output

[2] [0] 'np' is not recognized as an internal or external command,
[2] [0] operable program or batch file.
[2] [1] 'run' is not recognized as an internal or external command,
[2] [1] operable program or batch file.
[2] [2] 'lint"' is not recognized as an internal or external command,
[2] [2] operable program or batch file.
[2] [3] 'webpac' is not recognized as an internal or external command,
[2] [3] operable program or batch file.
[2] [4] 'run' is not recognized as an internal or external command,
[2] [4] operable program or batch file.
[2] [5] 'serve"' is not recognized as an internal or external command,
[2] [5] operable program or batch file.
[2] [4] run exited with code 1
[2] [3] webpac exited with code 1
[2] [2] lint" exited with code 1
[2] [1] run exited with code 1
[2] [0] np exited with code 1
[2] [5] serve" exited with code 1

I did manage to get it working again by changing my package.json scripts around

  "scripts": {
    "serve": "concurrently \"npm run lint\" \"webpack --watch\" \"nodemon\"",
    "build": "npm run lint && webpack",
    "test": "jest --forceExit",
    "lint": "tslint -c tslint.json -p tsconfig.json",
    "debug": "npm run build && node --debug-brk=3000 dist/index.js"
  },

And now starting my app with npm run serve instead of npm start.

gustavohenke commented 6 years ago

Given no one commented on this issue for the past year, I'm closing it (yes, I'm also guilty of it).

If you still find these bugs while using concurrently, please open a new issue providing a self-enclosed example.

Thanks!