vscode launching function app in lerna monorepo












1















First, I have a monorepo that is structured like so:



repo-name/
packages/
backend/
frontend/
.vscode/


The backend is an Azure function app structured like so:



backend/
functions/
funcOne/
funcTwo/
scripts/
start-debug.sh
package.json


Second, for the backend's package.json, I have a script:



  "debug": "npm run build && FUNCTION_APP_PORT=7071 ./scripts/start-debug.sh",


The start-debug.sh script looks like this:



#!/bin/bash 
set -e
cd ./functions
func extensions install
func host start -p $FUNCTION_APP_PORT --debug VSCode


I'm trying to write a launch configuration so that I can debug my functions in VSCode.



I have tried a number of variations based on what I have found out there, but nothing seems to work. Does anyone have any suggestions?



Here's my latest attempt:



{
"name": "Launch Backend Functions",
"type": "node",
"request": "launch",
"address": "localhost",
"protocol": "inspector",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/lerna",
"runtimeArgs": [
"exec",
"--scope",
"actual-name-of-backend-package",
"--",
"npm"
],
"args": ["run", "debug"],
"port": 1234
}









share|improve this question

























  • Hey I've written a small vscode extension that can help you differentiate easily when you're working on a serverside file and a clientside file based on regex and colors. Maybe helpful to you! marketplace.visualstudio.com/…

    – orepor
    Jan 25 at 12:48
















1















First, I have a monorepo that is structured like so:



repo-name/
packages/
backend/
frontend/
.vscode/


The backend is an Azure function app structured like so:



backend/
functions/
funcOne/
funcTwo/
scripts/
start-debug.sh
package.json


Second, for the backend's package.json, I have a script:



  "debug": "npm run build && FUNCTION_APP_PORT=7071 ./scripts/start-debug.sh",


The start-debug.sh script looks like this:



#!/bin/bash 
set -e
cd ./functions
func extensions install
func host start -p $FUNCTION_APP_PORT --debug VSCode


I'm trying to write a launch configuration so that I can debug my functions in VSCode.



I have tried a number of variations based on what I have found out there, but nothing seems to work. Does anyone have any suggestions?



Here's my latest attempt:



{
"name": "Launch Backend Functions",
"type": "node",
"request": "launch",
"address": "localhost",
"protocol": "inspector",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/lerna",
"runtimeArgs": [
"exec",
"--scope",
"actual-name-of-backend-package",
"--",
"npm"
],
"args": ["run", "debug"],
"port": 1234
}









share|improve this question

























  • Hey I've written a small vscode extension that can help you differentiate easily when you're working on a serverside file and a clientside file based on regex and colors. Maybe helpful to you! marketplace.visualstudio.com/…

    – orepor
    Jan 25 at 12:48














1












1








1








First, I have a monorepo that is structured like so:



repo-name/
packages/
backend/
frontend/
.vscode/


The backend is an Azure function app structured like so:



backend/
functions/
funcOne/
funcTwo/
scripts/
start-debug.sh
package.json


Second, for the backend's package.json, I have a script:



  "debug": "npm run build && FUNCTION_APP_PORT=7071 ./scripts/start-debug.sh",


The start-debug.sh script looks like this:



#!/bin/bash 
set -e
cd ./functions
func extensions install
func host start -p $FUNCTION_APP_PORT --debug VSCode


I'm trying to write a launch configuration so that I can debug my functions in VSCode.



I have tried a number of variations based on what I have found out there, but nothing seems to work. Does anyone have any suggestions?



Here's my latest attempt:



{
"name": "Launch Backend Functions",
"type": "node",
"request": "launch",
"address": "localhost",
"protocol": "inspector",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/lerna",
"runtimeArgs": [
"exec",
"--scope",
"actual-name-of-backend-package",
"--",
"npm"
],
"args": ["run", "debug"],
"port": 1234
}









share|improve this question
















First, I have a monorepo that is structured like so:



repo-name/
packages/
backend/
frontend/
.vscode/


The backend is an Azure function app structured like so:



backend/
functions/
funcOne/
funcTwo/
scripts/
start-debug.sh
package.json


Second, for the backend's package.json, I have a script:



  "debug": "npm run build && FUNCTION_APP_PORT=7071 ./scripts/start-debug.sh",


The start-debug.sh script looks like this:



#!/bin/bash 
set -e
cd ./functions
func extensions install
func host start -p $FUNCTION_APP_PORT --debug VSCode


I'm trying to write a launch configuration so that I can debug my functions in VSCode.



I have tried a number of variations based on what I have found out there, but nothing seems to work. Does anyone have any suggestions?



Here's my latest attempt:



{
"name": "Launch Backend Functions",
"type": "node",
"request": "launch",
"address": "localhost",
"protocol": "inspector",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/lerna",
"runtimeArgs": [
"exec",
"--scope",
"actual-name-of-backend-package",
"--",
"npm"
],
"args": ["run", "debug"],
"port": 1234
}






azure visual-studio-code vscode-debugger lerna monorepo






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 21:05







westandy

















asked Nov 20 '18 at 20:49









westandywestandy

4691720




4691720













  • Hey I've written a small vscode extension that can help you differentiate easily when you're working on a serverside file and a clientside file based on regex and colors. Maybe helpful to you! marketplace.visualstudio.com/…

    – orepor
    Jan 25 at 12:48



















  • Hey I've written a small vscode extension that can help you differentiate easily when you're working on a serverside file and a clientside file based on regex and colors. Maybe helpful to you! marketplace.visualstudio.com/…

    – orepor
    Jan 25 at 12:48

















Hey I've written a small vscode extension that can help you differentiate easily when you're working on a serverside file and a clientside file based on regex and colors. Maybe helpful to you! marketplace.visualstudio.com/…

– orepor
Jan 25 at 12:48





Hey I've written a small vscode extension that can help you differentiate easily when you're working on a serverside file and a clientside file based on regex and colors. Maybe helpful to you! marketplace.visualstudio.com/…

– orepor
Jan 25 at 12:48












1 Answer
1






active

oldest

votes


















1














OK, here's the launch configuration in VSCode that worked for me:



{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"protocol": "legacy",
"processId": "${command:PickProcess}",
"port": 9229
},


My steps are



1) Go to my backend repo, and run npm run debug which runs my start-debug.sh script.



2) In VS Code, I attach to a nodejsWorker out of azure-function-core-tools.



Now, I can step through my functions.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401298%2fvscode-launching-function-app-in-lerna-monorepo%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    OK, here's the launch configuration in VSCode that worked for me:



    {
    "type": "node",
    "request": "attach",
    "name": "Attach by Process ID",
    "protocol": "legacy",
    "processId": "${command:PickProcess}",
    "port": 9229
    },


    My steps are



    1) Go to my backend repo, and run npm run debug which runs my start-debug.sh script.



    2) In VS Code, I attach to a nodejsWorker out of azure-function-core-tools.



    Now, I can step through my functions.






    share|improve this answer




























      1














      OK, here's the launch configuration in VSCode that worked for me:



      {
      "type": "node",
      "request": "attach",
      "name": "Attach by Process ID",
      "protocol": "legacy",
      "processId": "${command:PickProcess}",
      "port": 9229
      },


      My steps are



      1) Go to my backend repo, and run npm run debug which runs my start-debug.sh script.



      2) In VS Code, I attach to a nodejsWorker out of azure-function-core-tools.



      Now, I can step through my functions.






      share|improve this answer


























        1












        1








        1







        OK, here's the launch configuration in VSCode that worked for me:



        {
        "type": "node",
        "request": "attach",
        "name": "Attach by Process ID",
        "protocol": "legacy",
        "processId": "${command:PickProcess}",
        "port": 9229
        },


        My steps are



        1) Go to my backend repo, and run npm run debug which runs my start-debug.sh script.



        2) In VS Code, I attach to a nodejsWorker out of azure-function-core-tools.



        Now, I can step through my functions.






        share|improve this answer













        OK, here's the launch configuration in VSCode that worked for me:



        {
        "type": "node",
        "request": "attach",
        "name": "Attach by Process ID",
        "protocol": "legacy",
        "processId": "${command:PickProcess}",
        "port": 9229
        },


        My steps are



        1) Go to my backend repo, and run npm run debug which runs my start-debug.sh script.



        2) In VS Code, I attach to a nodejsWorker out of azure-function-core-tools.



        Now, I can step through my functions.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '18 at 21:04









        westandywestandy

        4691720




        4691720






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401298%2fvscode-launching-function-app-in-lerna-monorepo%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            'app-layout' is not a known element: how to share Component with different Modules

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            WPF add header to Image with URL pettitions [duplicate]