Electron require modules: due to diffrent working directory while runtime intellisense is not working











up vote
0
down vote

favorite












Im writing an electron-app with vs-code. First I had some problems with requiring local files as modules, but i managed to fix them. The only problem now ist that i've lost intellisens for these local modules.



Project structure:



+---app
| | config.json
| | index.html
| |
| +---css
| | style.css
| |
| +---js
| config.js
| render.js
|
| main.js
| package.json
| README.md


My goal: use the methods from config.js in render.js.



I realize by now why vs-code behaves like it does but I dont see any solution: when the application is running the current working direcotry(__dirname) is ./app so i have to require the config.js-file over require(./js/config). The downside ist i lose complete intellisense for this module.



When im developing and have the render.js file open the current directory from vs-code's point of view is ./app/js, so the relativ path to my module is ./config.js. Now i would have intellisense again but the application is not working anymore:
require(./config) results in error: cannot find module



Is there any way that the application runs and i get intellisense in vs-code? I am grateful for any help I can get.










share|improve this question


























    up vote
    0
    down vote

    favorite












    Im writing an electron-app with vs-code. First I had some problems with requiring local files as modules, but i managed to fix them. The only problem now ist that i've lost intellisens for these local modules.



    Project structure:



    +---app
    | | config.json
    | | index.html
    | |
    | +---css
    | | style.css
    | |
    | +---js
    | config.js
    | render.js
    |
    | main.js
    | package.json
    | README.md


    My goal: use the methods from config.js in render.js.



    I realize by now why vs-code behaves like it does but I dont see any solution: when the application is running the current working direcotry(__dirname) is ./app so i have to require the config.js-file over require(./js/config). The downside ist i lose complete intellisense for this module.



    When im developing and have the render.js file open the current directory from vs-code's point of view is ./app/js, so the relativ path to my module is ./config.js. Now i would have intellisense again but the application is not working anymore:
    require(./config) results in error: cannot find module



    Is there any way that the application runs and i get intellisense in vs-code? I am grateful for any help I can get.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Im writing an electron-app with vs-code. First I had some problems with requiring local files as modules, but i managed to fix them. The only problem now ist that i've lost intellisens for these local modules.



      Project structure:



      +---app
      | | config.json
      | | index.html
      | |
      | +---css
      | | style.css
      | |
      | +---js
      | config.js
      | render.js
      |
      | main.js
      | package.json
      | README.md


      My goal: use the methods from config.js in render.js.



      I realize by now why vs-code behaves like it does but I dont see any solution: when the application is running the current working direcotry(__dirname) is ./app so i have to require the config.js-file over require(./js/config). The downside ist i lose complete intellisense for this module.



      When im developing and have the render.js file open the current directory from vs-code's point of view is ./app/js, so the relativ path to my module is ./config.js. Now i would have intellisense again but the application is not working anymore:
      require(./config) results in error: cannot find module



      Is there any way that the application runs and i get intellisense in vs-code? I am grateful for any help I can get.










      share|improve this question













      Im writing an electron-app with vs-code. First I had some problems with requiring local files as modules, but i managed to fix them. The only problem now ist that i've lost intellisens for these local modules.



      Project structure:



      +---app
      | | config.json
      | | index.html
      | |
      | +---css
      | | style.css
      | |
      | +---js
      | config.js
      | render.js
      |
      | main.js
      | package.json
      | README.md


      My goal: use the methods from config.js in render.js.



      I realize by now why vs-code behaves like it does but I dont see any solution: when the application is running the current working direcotry(__dirname) is ./app so i have to require the config.js-file over require(./js/config). The downside ist i lose complete intellisense for this module.



      When im developing and have the render.js file open the current directory from vs-code's point of view is ./app/js, so the relativ path to my module is ./config.js. Now i would have intellisense again but the application is not working anymore:
      require(./config) results in error: cannot find module



      Is there any way that the application runs and i get intellisense in vs-code? I am grateful for any help I can get.







      javascript node.js visual-studio-code electron intellisense






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 14:01









      saftimufti

      364




      364
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          I found the problem.. I was referencing the render.js in the index.html file. If I load it with require(./app/js/render) in the app.js file everything works fine, including intellisens.






          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',
            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%2f53227152%2felectron-require-modules-due-to-diffrent-working-directory-while-runtime-intell%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








            up vote
            0
            down vote



            accepted










            I found the problem.. I was referencing the render.js in the index.html file. If I load it with require(./app/js/render) in the app.js file everything works fine, including intellisens.






            share|improve this answer

























              up vote
              0
              down vote



              accepted










              I found the problem.. I was referencing the render.js in the index.html file. If I load it with require(./app/js/render) in the app.js file everything works fine, including intellisens.






              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                I found the problem.. I was referencing the render.js in the index.html file. If I load it with require(./app/js/render) in the app.js file everything works fine, including intellisens.






                share|improve this answer












                I found the problem.. I was referencing the render.js in the index.html file. If I load it with require(./app/js/render) in the app.js file everything works fine, including intellisens.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 14:59









                saftimufti

                364




                364






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53227152%2felectron-require-modules-due-to-diffrent-working-directory-while-runtime-intell%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

                    Landwehr

                    Reims

                    Schenkenzell