N
N
nickerlan2019-03-01 22:21:59
JavaScript
nickerlan, 2019-03-01 22:21:59

How to manage modules?

Here I wrote a couple of nice classes on nodejs. In my case - wrappers around the API of several services
. Now I want to use them as an "arsenal" in different projects.
I mostly run projects alone, on the same machine. Sometimes several people join.
I see I have written How now to turn this into a "universal code base"? At least for personal use? Tried the github repository. Then npm publish. On a new project npm install myscript Now how can I quickly make changes to this module? Edit directly in node_modules (looking for your module each time in this fiery sheet), then push changes directly from there, and then publish them?
const myscript = require('./myscript')
It’s also good to consider that I often work on several projects in parallel on the same local machine and I want to always have the up-to-date version of my modules, and then calmly deploy all this without problems.
How is it humanly done?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Shvets, 2019-03-01
@Xuxicheta

You can pull the module not from npm, but directly from the git repository.
You can also publish updated versions in npm.
If you need to edit the module in place, then it's better to include this code as a git submodule rather than an npm package. Editing directly in node_modules is not worth it.

V
Vitaly Stolyarov, 2019-03-01
@Ni55aN

If changes need to be made frequently, comparable to changes in the project itself, then this should not be taken out as a separate module.
And now how can I quickly make changes to this module? Edit directly in node_modules (looking for your module each time in this fiery sheet), then push changes directly from there, and then publish them?
You can install a local package (npm i ../module-folder): in the project itself (package.json will contain the path to the package, instead of the npmjs version) or select a dev wrapper project so that you don’t swap this package in the main project every time between local and remote. In this way, you can normally edit the package with the same HMR, without editing node_modules and publishing for every sneeze

R
Ruslan Lopatin, 2019-03-02
@lorus

There are more npm link( yarn link). Useful to debug changes locally. But as soon as debugged - publish. I don't see a problem with this.
If you don't want to publish manually, teach CI to do it automatically. For example, when making changes to the master branch, generate and publish the dev version. See how many dev versions the same typescript has .
If changes are constantly made to several modules at once, then there is no point in such modules. Consider putting them in the same repository. By the way, yarn understands links directly in package.json:

{
  "devDependencies": {
    "my-local-dep": "link:../my-local-dep"
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question