node js. install npm packages from hard disk - javascript

How can I install npm package to Node.JS project from hdd. I think admin at work blocked npm.
I installed npm and when I try to write in cmd npm install express for example I got connection timeout.
But I have find back door, I can clone npm package via git desktop from github to hdd.
Somebody can help me ?

You won't be able to regularly install and update packages if your IT team blocked all access to all registries — you would need to essentially make a backup of thousands of packages to your computer for that to work. What you could try is using a different registry, for example npm --registry [registry url] install express. This is a list of some registry mirrors. If your workplace uses JS though, I would talk with the IT team to make sure they can unblock the main registry.

Related

NPM peer dependencies issue while building vis-timeline locally

I am using vis-timelime in one of my projects. I have done some changes in vis-timeline, then locally build it and using it as dependency in my project. While doing so, vis-timeline is getting installed properly but i believe the peer dependencies of vis-timeline are not coming. Do note that I'm using npm version - 7.6.3.
cd vis-timeline;
//added some console logs in few files
npm install;
npm run build;
Then in my project-
cd my-app
npm install local-path-to-my-vis-timeline
Running above commands install the vis-timeline in node_modules of my-app. However, other peer dependencies of vis-timeline like vis-data, etc. do not come automatically. Since I am using npm version 7.6.3, wasn't it supposed to happen automatically?? If not, any graceful solution to this?
Or let me know of any other better way to locally do changes in vis-timeline library and use it in my local project for debugging.
Sounds like an issue with npm. This post has a list of solutions that might work.
Otherwise, maybe try using yarn instead of npm?

Install npm packages locally to be accesed by other projects

I'd like to know how it works npm comparing to Maven (I come from a Java background) in terms of managing packages.
I have created a generic component using Angular 4, this component will be used in many projects. So, I have published it to our nexus registry and then, from the client projects I just import the package so that the package gets downloaded from the registry and everything works fine.
Now, for development, I don't want to be publishing to the registry every single time I do a modification in the generic component and rebuilding the clients.
I would like instead to do it like we do with Maven in Java, we install the artifact in our local repo, and the artifact will be picked up from the local repo before going to the global 'artifactory', but I see that when we install a module using npm, it gets installed inside node_modules folder inside the same project, so that the module is not available for any other project.
How should I do that? In other words, does npm keep a local repository where the installed modules are accessible to any other projects without the need of publishing to the global registry?
Thanks
use --global switch behind the npm install command to install the package of your choice global.
hope that helps
To make something available to the rest of the system's node package environment through npm, you can install it globally (which is local to your system) rather than locally (which is local to your project). You can see documentation for global-ness on installs in this part of the NPM documentation.
npm i -g package names here
npm install --global package names here
You can update your globally installed packages as you would a locally installed one as well when you need to.
npm update -g package names here
(or all of them without specifying)
npm update -g
See the full NPM documentation pages for more detailed flags, etc.
If you're hoping to use your own packages in a managed environment, you can either publish them as private modules or keep them in a VCS (mostly git) and reference them by the appropriate method for that VCS in your projects' package.json scheme through the dependencies block for github urls or more generally other git hosts, like
"dependencies": {
"myComponent": "user/repo#feature\/branch",
"otherComponent": "git+https://myGitHost.tld/.../projectName.git#commit"
}

How to install Node.js or npm on Xampp

I'm new, so please excuse any mistakes.
I am trying to develop a web application locally using XAMPP. I intend to deploy using a hosted web service. XAMPP was a very convenient way to get me up and programming without any fuss.
There are several github javascript libraries that look like they can only be installed with npm. Does this mean that I cannot use them? The specific one that I'm currently having a problem with is: https://github.com/selz/plyr. Or, is it possible to install npm on my XAMPP server? I have a windows machine.
Thank you very much in advance for your help.
is it possible to install npm on my XAMPP server
You will not be installing NPM on your server, you will be installing it on your machine (think of it as a regular program you install on your PC) (if your server happens to be your PC as well, then, well, you are technically installing it on your server)
In order to be able to use NPM though, since NPM is written in JavaScript, you will need to install Node.js, also on your machine.
So, head over to the Node.js site and download and install Node. NPM is included in the installer and will be installed alongside Node.
After that is done, installing NPM packages is simply a matter of heading to your desired directory and executing npm install <PACKAGE_NAME> there.
In general, XAMPP helps you with your back end. Not your front end.
Useful links:
https://docs.npmjs.com/
Does this mean that I cannot use them?
No. You can install node at https://nodejs.org and then use npm through your windows command line to install packages. To test this, just
Install NodeJS
Open Command Line
Make a new folder under your user folder called test mkdir test
cd into that folder on Windows Command Line cd test
Create a new project with npm init -y *note this creates a
package.json file for you
Now you start installing packages with npm install <package>
--save * --save saves the package info in your package.json file (recommended). There is also -g wihch means the package will
be installed globally (usually you don't want this and only want it
locally to your project).
That's how you use NodeJS. If you want to use that with XAMPP then you need to do the same thing but instead of using your user folder (C:\users\yourname) you need to use the htdocs folder of XAMPP (usually C:\xampp\htdocs)

install sails manually on ubuntu server

My Ubuntu server is behind firewall.hence when ever I try to run command to install sails via putty using command npm install sails -g ,I get error Error: connect ECONNREFUSED.
There fore I though if I can download the sails package on to my local and then moving the package manually on firewall server and installing it. I tried looking for some help on web but could not get. Please guide how to proceed
If your computer is not connected to the internet npm will not work.
If you have another computer connected to the internet, you can run the npm commands there and afterwards copy the contents to the other computer. (e.g. via USB stick)
In most cases you should have no problems, even on different operating systems.
Note on global modules: For global modules (e.g. gulp, bower, forever) you will not be able to install into node_modules using this technique. However, you can install them locally by saving them to your package json and running them from their local path.
e.g.
npm install --save forever
./node_modules/forever/bin/forever
Check the files system for the exact path.

How can I use nodemon without using npm install

My network doesn't allowed using npm install.
How can I install and use nodemon? Node run only after set PATH variables on windows I tried set the path for nodemon, but I dont have results.
The easiest way to install an npm package is going to be to either tunnel out of your network with a proxy, or to simply install the package while you're on a different network. The reason it's not as simple to just download it is that npm packages have a list of dependencies that need to be installed along with it. Npm takes care of installing the dependency graph for you. If you try to install it manually you would have to manually go over nodemon's package.json file and install all of its dependencies. That might not be so bad until you realize that you then have to go through all those dependencies and install their dependencies, and so on...
I'm not at all affiliated with IPVanish but I recently signed up for their service for the same reason as you. My computer has a VPN configured that connects to an IPVanish server and then my computer tunnels all internet traffic through that VPN. It's nice for simple anonymous web browsing, but more importantly there is no way for network admins here to see where any of my traffic is going. To them it appears that I'm just talking to a random server. They'd have to block every single IPVanish server (and there's a lot!).
There are other alternatives but that one had good reviews and it's only $10 a month. I haven't tried any others but I'm sure they're just as good.
If tunneling out of your network or installing the module on a different network isn't an option, I'm happy to install it myself and upload a zip of the completed install to Google Drive so you can just extract it to the global npm folder. However, that would obviously not be a permanent solution for you and even though I have good intentions, you don't know me and I don't recommend downloading random stuff off of a stranger's Google Drive.
I recommend getting a friend to do the following from another network:
Install nodemon: npm install -g nodemon
Find where global npm modules install to: npm config get prefix
Navigate to the global npm module path, find the nodemon directory, and zip it up.
Email/Dropbox you the archived module.
On your machine figure out where global npm modules install to: npm config get prefix
Extract the nodemon zip to that location.

Categories

Resources