npm could not find module '../lib/npm.js' - javascript

I am trying to use nodejs and npm on a CentOS 7 machine. The machine cannot connect to the Internet, so I copy the node-v6.2.1-linux-x64 folder with some lib modules inside to the machine. But the output shows Error: Cannot find module '../lib/npm.js'. I wonder if it is the correct way to install nodejs offline or modules. Any helps? Thx.

It wouldn't work because the node modules depend to your operating system.
For example , lets say I have a project with tons of node dependencieses and I ran npm install on my Microsoft machine, when I copy my files and try to run it in Apple , it wouldn't work.
You have to use npm i seperetly on different machines.
Maybe this link here can help you to get your npm modules without internet . ==>
https://github.com/npm/npm/issues/1349

Related

'run-s' is not recognized as an internal or external command, operable program or batch file

I surprisingly got that issue out of nowhere, when I was trying to use the npm link command testing my local package. Any thoughts?
Windows 10
node 15.9.0
npm 8.12.2
Seems that the issue was because my npm version didn't match my node version.
I was trying to install that 'run-s' package globally but it didn't help. I checked my environment variables but it didn't help either.
After all I just simply uninstalled nodejs, deleted all the files that it left and installed the needed version again (12.22.12 in my case) using "windows-nvm" and now everything runs smoothly.
Now my NodeJS version is 12.22.12
my NPM version is 6.14.16
Hope it will help somebody

Node installed but node cannot be found in Ubuntu VPS

I installed node via NVM. I installed node 0.10.32. using NVM 0.25.0
When I do node -v I get
-bash: /root/.nvm/v0.10.32/bin/node: No such file or directory
when I do npm v I get
/root/.nvm/v0.10.32/bin/npm: 2: exec: /root/.nvm/v0.10.32/bin/node: not found
All those directories exist and node executable is in it but they are reading as not found. Node seems to be installed but I am unable to use it. I am not sure how to fix this issue. Any ideas will be greatly appreciated
Check that your ~/.bash_profile has this:
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
https://github.com/creationix/nvm/issues/576
A lot of things can be wrong here from what you describe. Generally I don't recommend using nvm to install Node on servers. It works fine for your own work on a local machine but when you need to be sure what is installed and where, I recommend doing a real installation.
I recently wrote a tutorial on how to install Node on Linux:
https://gist.github.com/rsp/edf756a05b10f25ee305cc98a161876a
It is specifically about version 6.7.0 but just change the version number to use any other version of Node.
You can see other answers showing how to install Node properly and troubleshoot if it isn't installed correctly:
Run npm as superuser, it isn't a good idea?
node 5.5.0 already installed but node -v fetches with "v4.2.1" on OS X & homebrew?
Just get the binary or source package of the version that you need, install it where you want and it will work. The most reliable way is to install a source package because you can run make test before you install and because npm will have the correct shebang line (which may not always be the case with binary distribution - which, incidentally, is also used by nvm). No need to use nvm or any other tool to do that.
The nvm is great if you need to quickly switch Node versions during development on your local machine but if you want a reliable way to install Node on the server then it's best to install it normally.

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.

Problem with installing Node.JS on Windows

I'm trying to install Node.JS on Windows 7 with help of this tutorial.
I downloaded Cygwin, installed it. I have installed Python 2.7.
After this i downloaded last version of Node.JS in tar.gz. Than I opened cygwin bash and typed this command there:
tar zxvf node<tab>
It unzipped it to directory: node-v0.4.2
But what i need to do if i have python installed?
I tried to type:
make test
and got error message: make: command not found
I will be very grateful for any help!
Did you install all the required packages? Run setup.exe again and check.
I think the issue might be that the environment variables in Cygwin need to be configured:
Getting Make to place nice with Cygwin

Categories

Resources