Giter VIP home page Giter VIP logo

Comments (9)

kchindam-infy avatar kchindam-infy commented on August 29, 2024

@cdoublev The default behavior frpm npm 9 is to install linked dependencies instead of crating symlinks. If you need file dependencies to be links you need, then use --install-links=false.

from cli.

cdoublev avatar cdoublev commented on August 29, 2024

I want files and dependencies to be installed. I find this more convenient than stashing unstaged files and checking out the desired ref.

Thanks for the tip!

from cli.

kchindam-infy avatar kchindam-infy commented on August 29, 2024

@cdoublev As i mentioned you could use --install-links=false for files.

from cli.

cdoublev avatar cdoublev commented on August 29, 2024

npm i ../repo creates a symlink node_modules/repo -> ../repo. Assuming repo has a dependency, it is not installed in node_modules.

npm i --install-links ../repo creates node_modules/repo with all files from ../repo. Assuming repo has a dependency, it is also installed in node_modules.

But I need files and dependencies from ../repo#<commit-or-tag> to be installed in node_modules, not the current files in ../repo.

Sorry if I misunderstand you.

from cli.

kchindam-infy avatar kchindam-infy commented on August 29, 2024

Thanks for the clarification, based on your requirement you can install the contents and dependencies from a specific commit or tag in your local repo and you can use the following command
npm install git+file:///path/to/repo#commit-or-tag

This will clone the repo at the specified commit or tag and install the dependencies as per the package.json for that commit.

from cli.

cdoublev avatar cdoublev commented on August 29, 2024

Ah, it works with git+file:///absolute-path, thansk!

This SO answer suggests that git ls-remote <relative-path> works inexpectedly, and that git -C <relative-path> rev-parser should be used instead. Not sure what happens under the hood of npm when using git+file:///absolute-path vs. git+file:relative-path.

Might be worth adding a note about this, isn't it?

from cli.

cdoublev avatar cdoublev commented on August 29, 2024

Actually, it does not work: npm creates a symlink node_modules/repo -> ../^git+file:/absolute-path/repo.

Never mind, I made a typo in the dependency version.

from cli.

kchindam-infy avatar kchindam-infy commented on August 29, 2024

Thanks for confirming, glad the provided solution worked for you.

from cli.

cdoublev avatar cdoublev commented on August 29, 2024

Ah, too bad, leaving this bug unfixed and this requirement (git+file only accepts absolute paths - starting with / - preceded by git+file://) undocumented seem to favor a poor user experience.

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.