Git Product home page Git Product logo

npm-link-copy's Introduction

DEPRECATED: Please use npm-link-better

npm-link-copy

Alternative to npm link that works by copying files instead of linking.

Why?

Suppose you have the following setup:

/home
├───your-projects
│   └───some-project
├───your-npm-libs
│   └───your-awesome-module

Where some-project uses your-awesome-module.

While developing locally, you'd obviously want to make use of npm link

~/your-npm-libs/your-awesome-module $ npm link
~/your-projects/some-project $ npm link your-awesome-module

While this does link your-awesome-module inside some-project/node_modules and you can carry on as though it's actually installed, but internally node uses fs.realPath and therefore knows that your-awesome-module is actually in ~/your-npm-libs/your-awesome-module and not really in some-project/node_modules/your-awesome-module. This reflects in things like require calls or access to __dirname from your module or its dependencies which sometimes causes issues.

So to help with that, this tool actually copies your-awesome-module in some-project/node_modules/your-awesome-module and optionally keeps it updated (with --watch)

One downside is that you need to run it every time you make changes to your-awesome-module

Install

npm install -g laggingreflex/npm-link-copy

Usage

npm-link-copy [..modules] [options]
  • --watch, -w Watch for changes
  • --ignored, -i [defalut:['node_modules', '.git']] Ignored dirs

Libraries used

npm-link-copy's People

Contributors

laggingreflex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

blissi

npm-link-copy's Issues

All files are emptied

I now you are thinking about a rewrite, but I just found a dangerous problem with npm-link-copy, so I'm creating this issue.

What I did

I first executed npm link my-dependency out of habbit, but then remembered that there is a better solution. So I also did npm-link-copy my-dependency.

Result

Then I got lots of errors, like this one:

[nlc] [error] [my-dependency] Cannot copy package.json ENOENT: no such file or directory, open '/home/user/.local/lib64/node_modules/my-dependency/package.json'   

Also all the files in my-dependency are now empty. (Luckily .git was not touched though.)

Explanation

First I did not understand why all this is happening, but I think I found the reason.
npm link creates a link from ./node_modules/my-dependency to ~/.local/lib64/node_modules/my-dependency, which is itself a link to the development directory of my-dependency.
So when npm-link-copy tries to copy the files from ~/.local/lib64/node_modules/me-dependency, it will try to overwrite them with themselves.

Allow module location as parameter

The command npm link allows to link a package in one step instead of two, by giving the location of it: npm link ../my-other-package. It would be nice, if this was also possible with npm-link-copy.

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.