How to configure any node module (e.g. json-server) to a offline pc (not connected to internet but to the local network)
- Node.js Version:
- OS: Windows 10
- Scope (install, code, runtime, meta, other?):
- Module (and version) (if relevant): json-server
How to configure any node module (e.g. json-server) to a offline pc (not connected to internet but to the local network)
I tried fol steps:-
- Over the Online PC:- created a folder "json server" went inside the folder "json server" using cmd of windows OS. executed : npm install -g json-server executed: json-server --watch db.json It worked fine! Therefore I copied this folder to offline pc (having node js installed) and tried to run the same command: json-server --watch db.json
but this says json-server is not a valid command. So please help.
The action of conducting the original npm install -g command caused the installation action in your current working directory to also be conducted in a globally visible known location on your connected 'source' PC. It would have conducted that action by installing the json-server to a 'global-npm-directory' that was configured to already to be on your PATH (based on the existing location of where the node and npm tools - also executables - were respectively installed).
In only copying the resultant folder (contents?) to your offline PC, you didn't include the global package installation step relative to where npm knows where it (and the node executable) were installed on that target PC (which, might be the same location as your source PC!). Consequently, the copied executable content is not presented in a location that is on your PATH, and hence the command (package name = json-server) is not recognised as valid command (because its not a searched directory).
@shellberg I have no hesitation to admit that I am a newbie to node js. So would you mind telling the exact working steps to achieve the aim; "Download node js modules from an online PC and run these over offline PC ". I will appreciate if you please put these steps in points form. Thanks