How to have npm install a typescript dependency from a GitHub url?How can I remove a commit on GitHub?How can I determine the URL that a local Git repository was originally cloned from?How can I update NodeJS and NPM to the next versions?How do I update a GitHub forked repository?Find the version of an installed npm packageHow do I update each dependency in package.json to the latest version?How to install an npm package from GitHub directly?What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?What is the --save option for npm install?Why does “npm install” rewrite package-lock.json?

Aliens crash on Earth and go into stasis to wait for technology to fix their ship

How to fry ground beef so it is well-browned

If a planet has 3 moons, is it possible to have triple Full/New Moons at once?

Don’t seats that recline flat defeat the purpose of having seatbelts?

Why did C use the -> operator instead of reusing the . operator?

Does a large simulator bay have standard public address announcements?

Check if a string is entirely made of the same substring

"The cow" OR "a cow" OR "cows" in this context

Contradiction proof for inequality of P and NP?

Can an Area of Effect spell cast outside a Prismatic Wall extend inside it?

Critique of timeline aesthetic

Pre-plastic human skin alternative

Rivers without rain

Relationship between strut and baselineskip

How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?

"You've called the wrong number" or "You called the wrong number"

What does ゆーか mean?

Philosophical question on logistic regression: why isn't the optimal threshold value trained?

555 timer FM transmitter

How to display Aura JS Errors Lightning Out

Two field separators (colon and space) in awk

Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?

How to write a column outside the braces in a matrix?

How come there are so many candidates for the 2020 Democratic party presidential nomination?



How to have npm install a typescript dependency from a GitHub url?


How can I remove a commit on GitHub?How can I determine the URL that a local Git repository was originally cloned from?How can I update NodeJS and NPM to the next versions?How do I update a GitHub forked repository?Find the version of an installed npm packageHow do I update each dependency in package.json to the latest version?How to install an npm package from GitHub directly?What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?What is the --save option for npm install?Why does “npm install” rewrite package-lock.json?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








8















Consider the following scenario:



  • There is a code library. The library is written in TypeScript and the typescript code is published in GitHub. The package.json file has a build script which creates JavaScript files based on the TypeScript code and a publish script which then places the resulting JS files on npm.

  • I make a fork of the GitHub repo, make some modifications to the typescript files and push those changes to GitHub. (I also open a PR to the original GitHub repo but there is a time lage before these changes can be merged.)

  • I wish to consume these code changes in a downstream NPM package so in the downstream packages I change the reference (in the downstream's package.json file) to the modified package to the GitHub URL of my fork and do an npm install.

This doesn't work because:



  • The package.json file of the modified package does not list the typescript files in the dist field, only the automatically generated JS files so the TypeScript files are not pulled during the npm install.

  • The compiled JS files aren't present since they aren't checked in to GitHub.

How can I solve this? Is there a way that I can modify the behavoir of npm install so that it fetches files in the repo that aren't in dist and then runs the build script during the install?










share|improve this question






















  • I can only think of maintaining a separate build branch (a branch with same name as a folder would sometimes confuses Git, so avoid dist).

    – Franklin Yu
    Aug 30 '18 at 14:38

















8















Consider the following scenario:



  • There is a code library. The library is written in TypeScript and the typescript code is published in GitHub. The package.json file has a build script which creates JavaScript files based on the TypeScript code and a publish script which then places the resulting JS files on npm.

  • I make a fork of the GitHub repo, make some modifications to the typescript files and push those changes to GitHub. (I also open a PR to the original GitHub repo but there is a time lage before these changes can be merged.)

  • I wish to consume these code changes in a downstream NPM package so in the downstream packages I change the reference (in the downstream's package.json file) to the modified package to the GitHub URL of my fork and do an npm install.

This doesn't work because:



  • The package.json file of the modified package does not list the typescript files in the dist field, only the automatically generated JS files so the TypeScript files are not pulled during the npm install.

  • The compiled JS files aren't present since they aren't checked in to GitHub.

How can I solve this? Is there a way that I can modify the behavoir of npm install so that it fetches files in the repo that aren't in dist and then runs the build script during the install?










share|improve this question






















  • I can only think of maintaining a separate build branch (a branch with same name as a folder would sometimes confuses Git, so avoid dist).

    – Franklin Yu
    Aug 30 '18 at 14:38













8












8








8








Consider the following scenario:



  • There is a code library. The library is written in TypeScript and the typescript code is published in GitHub. The package.json file has a build script which creates JavaScript files based on the TypeScript code and a publish script which then places the resulting JS files on npm.

  • I make a fork of the GitHub repo, make some modifications to the typescript files and push those changes to GitHub. (I also open a PR to the original GitHub repo but there is a time lage before these changes can be merged.)

  • I wish to consume these code changes in a downstream NPM package so in the downstream packages I change the reference (in the downstream's package.json file) to the modified package to the GitHub URL of my fork and do an npm install.

This doesn't work because:



  • The package.json file of the modified package does not list the typescript files in the dist field, only the automatically generated JS files so the TypeScript files are not pulled during the npm install.

  • The compiled JS files aren't present since they aren't checked in to GitHub.

How can I solve this? Is there a way that I can modify the behavoir of npm install so that it fetches files in the repo that aren't in dist and then runs the build script during the install?










share|improve this question














Consider the following scenario:



  • There is a code library. The library is written in TypeScript and the typescript code is published in GitHub. The package.json file has a build script which creates JavaScript files based on the TypeScript code and a publish script which then places the resulting JS files on npm.

  • I make a fork of the GitHub repo, make some modifications to the typescript files and push those changes to GitHub. (I also open a PR to the original GitHub repo but there is a time lage before these changes can be merged.)

  • I wish to consume these code changes in a downstream NPM package so in the downstream packages I change the reference (in the downstream's package.json file) to the modified package to the GitHub URL of my fork and do an npm install.

This doesn't work because:



  • The package.json file of the modified package does not list the typescript files in the dist field, only the automatically generated JS files so the TypeScript files are not pulled during the npm install.

  • The compiled JS files aren't present since they aren't checked in to GitHub.

How can I solve this? Is there a way that I can modify the behavoir of npm install so that it fetches files in the repo that aren't in dist and then runs the build script during the install?







typescript github npm npm-install






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 28 '18 at 9:12









Jacob HorbulykJacob Horbulyk

4912623




4912623












  • I can only think of maintaining a separate build branch (a branch with same name as a folder would sometimes confuses Git, so avoid dist).

    – Franklin Yu
    Aug 30 '18 at 14:38

















  • I can only think of maintaining a separate build branch (a branch with same name as a folder would sometimes confuses Git, so avoid dist).

    – Franklin Yu
    Aug 30 '18 at 14:38
















I can only think of maintaining a separate build branch (a branch with same name as a folder would sometimes confuses Git, so avoid dist).

– Franklin Yu
Aug 30 '18 at 14:38





I can only think of maintaining a separate build branch (a branch with same name as a folder would sometimes confuses Git, so avoid dist).

– Franklin Yu
Aug 30 '18 at 14:38












1 Answer
1






active

oldest

votes


















1














The docs for the prepack script suggest that it is run after a dependency is installed from a git repo. Try putting something like this in the package.json of the git dependency:




"scripts":
"prepack": "call the build script"




This should build the package after you npm install it, which sounds like what you want to do. I'm not sure if there are any other problems you are having beyond that.






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%2f51078974%2fhow-to-have-npm-install-a-typescript-dependency-from-a-github-url%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














    The docs for the prepack script suggest that it is run after a dependency is installed from a git repo. Try putting something like this in the package.json of the git dependency:




    "scripts":
    "prepack": "call the build script"




    This should build the package after you npm install it, which sounds like what you want to do. I'm not sure if there are any other problems you are having beyond that.






    share|improve this answer



























      1














      The docs for the prepack script suggest that it is run after a dependency is installed from a git repo. Try putting something like this in the package.json of the git dependency:




      "scripts":
      "prepack": "call the build script"




      This should build the package after you npm install it, which sounds like what you want to do. I'm not sure if there are any other problems you are having beyond that.






      share|improve this answer

























        1












        1








        1







        The docs for the prepack script suggest that it is run after a dependency is installed from a git repo. Try putting something like this in the package.json of the git dependency:




        "scripts":
        "prepack": "call the build script"




        This should build the package after you npm install it, which sounds like what you want to do. I'm not sure if there are any other problems you are having beyond that.






        share|improve this answer













        The docs for the prepack script suggest that it is run after a dependency is installed from a git repo. Try putting something like this in the package.json of the git dependency:




        "scripts":
        "prepack": "call the build script"




        This should build the package after you npm install it, which sounds like what you want to do. I'm not sure if there are any other problems you are having beyond that.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 9 at 9:08









        NicholasNicholas

        33119




        33119





























            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%2f51078974%2fhow-to-have-npm-install-a-typescript-dependency-from-a-github-url%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

            1928 у кіно

            Захаров Федір Захарович

            Ель Греко