Reputation: 9763
I am trying to launch serverless from launch.json with no luck (despite it working perfectly from command line). How do I launch this?
Error:
Attribute 'program' does not exist
From the VSCode command line in the project root this works perfectly:
sls deploy --config slsSite.yml
Heres my current launch config:
{
"type": "node",
"request": "launch",
"name": "deploy site",
"preLaunchTask": "buildsite", //ref tasks.json
"program": "${workspaceFolder}\\serverless",
"args": ["deploy", "--config slsSite.yml"]
}
When I change the program to the path to the node module:
"program":"${workspaceFolder}\\serverless_site\\node_modules\\serverless\\bin\\serverless
I get:
This command can only be run in a Serverless service directory. Make sure to reference a valid config file in the current working directory if you're using a custom config file
Then I tried (in addition to the program line above):
"args": ["deploy", "--config ${workspaceFolder}\\slsSite.yml"]
and got the same error.
Upvotes: 2
Views: 254
Reputation: 1092
Serverless is looking at your current directory for the config file and cannot find it.
Looking at this line
"program":"${workspaceFolder}\\serverless_site\\node_modules\\serverless\\bin\\serverless
It looks like your workspaceFolder is not the root of the project. You can change that the Serverless project is the root of the workspace or change the cwd (current working directory) in launch.json like the following:
"cwd": "${workspaceFolder}\\serverless_site",
For future reference: Keep in mind that VSCode prefers to open the workspace at the root of the project. Only then does it know by default how to work with all the scripts.
Upvotes: 0
Reputation: 190
This command can only be run in a Serverless service directory
It looks like specific working directory is required. As far as I can tell, people usually run sls within their site folder (the folder with node_modules). I would consider trying to set working folder (in vscode it is usually "cwd") to "${workspaceFolder}\\serverless_site".
Attribute 'program' does not exist
has been resolved here by installing node modules locally.
Upvotes: 0