2

I want to use the VSCode debugger and want to set the environment variables before launching the app. The configuration in the Launch folder looks something like this.

    {
        "name": "Launch on iOS",
        "type": "nativescript",
        "request": "launch",
        "platform": "ios",
        "appRoot": "${workspaceRoot}",
        "sourceMaps": true,
        "watch": true,
        "environment": [
            {
                "BUILD_ENV": "local"
            }
        ]
    }

This doesn't seem to work though. I am using a Mac.

Problem reported by VSCode

lohiarahul
  • 1,432
  • 3
  • 22
  • 35
  • You mean the webpack environment variables? Have you defined `BUILD_ENV` in your `webpack.config.js`? If yes, then try adding `"tnsArgs":["--bundle", "--env.BUILD_ENV=local"]`. – Manoj Jan 11 '19 at 07:24
  • doesn't seem to pick up the value of the variable – lohiarahul Jan 14 '19 at 06:11

1 Answers1

0

Perhaps this works:

"env": {
  "BUILD_ENV": "local"
} 

or

"envFile": "${workspaceFolder}/.env",

or

"osx": {
    "environment": [
       {  "name": "", 
          "value": ""
      }
   ]
},

See platform-specific properties.

Mark
  • 143,421
  • 24
  • 428
  • 436
  • env isn't recognized either. I dont have separate env file. The variable is defined in the package.json – lohiarahul Jan 11 '19 at 03:16
  • So just typing "env" does that bring up any intellisense for a likely environment variable? I get both of the above options. – Mark Jan 11 '19 at 03:22
  • I also just found the "osx" option above as well from: https://stackoverflow.com/questions/29971572/how-do-i-add-environment-variables-to-launch-json-in-vscode [upvote the last answer.] – Mark Jan 11 '19 at 03:29
  • 1
    Tried this "osx": { "environment": [ { "name": "BUILD_ENV", "value": "local" }, { "BUILD_ENV": "local" } ] } – lohiarahul Jan 11 '19 at 05:55
  • this "osx": { "env": [ { "name": "BUILD_ENV", "value": "local" }, { "BUILD_ENV": "local" } ] } – lohiarahul Jan 11 '19 at 05:56
  • this "osx": { "BUILD_ENV": "local" } Nothing worked – lohiarahul Jan 11 '19 at 05:56