0

I have been told here that I could locally add globally installed packages using local-npm

I am aware that this is not a good practice, but as I may be forced to work offline for a few weeks I am desperate to get this set up so I do not face issues if I need any of my most commonly used packages.

I have already installed all the packages that I will need for the following weeks globally and I am now trying to understand how to use local-npm.

Am talking about front-end packages for me to use with react, such as redux, react-router, etc.

I have understood that I need to first:

  • install local-npm globally (done)
  • run npm-local in my project (the terminal does not recognize this command) I have also tried local-npm run start with no success anyways.
  • set the registry to npm set registry http://127.0.0.1:5080
  • then install whatever a want npm intall redux-thunk, for instance.

I am surely doing something wrong.

After a set the registry, turn the wiFi off and try to install npm install <package name> in my project nothing happens.

THanks and sorry for the dumb question as I am still a beginner to npm and still going to start the back-end journey.

P.S - I have read the Local-npm docs so please don't answer just pointing me there, but please give me a demo example, or something alike.

1 Answer 1

1

I know this is an entirely separate technology, but I'd like to suggest that you try out pnpm. https://pnpm.js.org. It's essentially a drop in replacement for npm.

Pnpm works by caching your installs to one central location and then creating symlinks to that location to the node_modules folder.

Pnpm will allow you to work offline, provide very fast installs (as it's just a symlink), and you don't need to pollute your global installs.

https://pnpm.js.org/en/cli/install there's an option for installing fully offline once the modules are cached: pnpm i --offline

Sign up to request clarification or add additional context in comments.

8 Comments

thanks! I will take a look and return to you asap in case I have any doubts
so I start by running npx pnpm add -g pnpm? to install it globally? What is the difference of running the first command to just using pnpm install?
The first command uses pnpm to install itself (because you don't have pnpm installed yet) so that it can be used to upgrade itself. The second command uses pnpm to install something with an already existing pnpm. add and install are synonyms
where do I run pnpm i --offline? inside my project folder? and when I try using any command starting with pnpm it does not reconize pnpm I get command not found: pnpm
You'd use pnpm install in your project folders (after you delete any existing node_modules folders). If pnpm is saying that the command isn't found, did you globally install it by running that first command? For the offline installs, you need to let it build up it's cache first by installing modules with it normally.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.