Alvaro Lorente
Alvaro Lorente

Reputation: 3084

Path to application with spaces in package.json script

I am having problems with strings and spaces. when creating an alias for running a command in package.json (it fails becase cuts the command at the first space).

{
  "scripts": {
    ...
    "react-native-debugger:osx": "/Applications/React Native Debugger.app/Contents/MacOS/React Native Debugger"
    ...
  }
}

I require this, to be able to automate starting the environment to develop react native apps, and escaping using \ does not work.

Upvotes: 6

Views: 7709

Answers (2)

PDHide
PDHide

Reputation: 19949

  "scripts": {
    "test": ".\\\"node modules\"\\.bin\\\"some folder\"\\protractor conf.js"
  },

use back slash and double quotes for windows.

Upvotes: 4

Alvaro Lorente
Alvaro Lorente

Reputation: 3084

I dont know if there is a better solution because the solution but the solution for me was to set the strings with spaces in single quotes (')

{
  "scripts": {
    ...
    "react-native-debugger:osx": "/Applications/'React Native Debugger.app'/Contents/MacOS/'React Native Debugger'"
    ...
  }
}

Upvotes: 5

Related Questions