Here are the steps I am following:
First, I login to my account using SSH.
Then, I install nvm using
wget -qO- https://cdn.rawgit.com/creationix/nvm/master/install.sh | bash
Then, I restart the shell
Then, I install node using
nvm install stable
But, when I check for the version of the node using the following, it says 'command not found'
node --version
If it helps, here are other things I tried:
nvm list
Also, here are the contents of the .nvm folder (which is inside the root folder):
I suppose N/A indicates that node is not available.
To sum it up, is it possible at all to use node.js on a shared hosting plan? If, yes, what can I do to make it work?
PS: I have been getting suggestions to use other plans like Heroku etc. Although, I have already invested a lot in this shared hosting plan (on GoDaddy), so I would really like if I can host nodeJS applications here.
PPS: I am new to programming, so please bear with any ignorance.
Try installing node like this
nvm install node
Then, crucially
nvm alias default node
Now running
node -v
Should display correctly
First of all shared server wont allow you to install anything on their server.
If you can able to install node on your shared server then you are pretty lucky.
To run node --version command, the node command should be in your path. On shared server, it might not be allowed.
So I think you need to check with full path like `/usr/bin/node --version'
(check your installation path)
Related
We have a dedicated server for Azure Devops hosted agents. The server runs all the pipelines we have. Now we have run into an issue where one project requires node.js version 8, and one project requires version 10 or 12.
So we can't just update the node.js installation on the server.
Microsoft offers the Node.js Tool installer task, but the description says it will add it to the PATH environment variable. We haven't run the installer task yet (don't want to break the builds).
Has anyone tried installing multiple versions of node.js on one server? Is it possible? Or is the task only meant to be used in a hosted (short-lived) build agent?
This is fine and it is also mention in troubleshoot section
If you're using nvm to manage different versions of Node.js, consider switching to the Node Tool Installer task instead. (nvm is installed for historical reasons on the macOS image.) nvm manages multiple Node.js versions by adding shell aliases and altering PATH, which interacts poorly with the way Azure Pipelines runs each task in a new process. The Node Tool Installer task handles this model correctly. However, if your work requires the use of nvm, you can add the following script to the beginning of each pipeline:
steps:
- bash: |
NODE_VERSION=12 # or whatever your preferred version is
npm config delete prefix # avoid a warning
. ${NVM_DIR}/nvm.sh
nvm use ${NODE_VERSION}
nvm alias default ${NODE_VERSION}
VERSION_PATH="$(nvm_version_path ${NODE_VERSION})"
echo "##vso[task.prependPath]$VERSION_PATH"
Then node and other command-line tools will work for the rest of the pipeline job. In each step where you need to use the nvm command, you'll need to start the script with:
- bash: |
. ${NVM_DIR}/nvm.sh
nvm <command>
So to sum up it is fine to use Node Tool Installer but if you decide to use nvm pleace keep in mind above comments.
How about using nvm
It's a good tool to support multiple versions of node.js. It is used a lot.
for example
nvm install v8
nvm install v10
nvm install v12
# first terminal
nvm use 8
npm install
node node_v8_server.js
# second terminal
nvm use 10
npm install
node node_v10_server.js
# third terminal
nvm use 12
npm install
node node_v12_server.js
I took a Vue 2 online course and it did show (but didn't really explain) how to install node.js, npm and vue. Currently using vue-cli to set up my project using vue init webpack-simple. Problem is I have a Windows desktop and a Mac laptop. I'm using Box cloud on both but I need to have 2 separate folders for the same project. Basically, project-1-windows and project-1-mac.
I can't run npm run dev on the project-1-mac while on Windows 10 and vice versa. The only way I know to run both is to delete the node_modules folder and run npm install. However it takes a while for the files to download. Is there an easier way to do this?
It looks like you want either GitHub/BitBucket/friends or (for much more complex set-ups) Docker.
I will explain only the first (easier) option. To set-up docker, you rather go to its docks.
So, for GitHub/BitBucket/friends way, you need some one-time set-up (you have to do all of this in terminal of your machine. I don't go too deep into details because you may find corresponding docks for each thing easily by googling it).
Install git if needed on both machines. On mac, you just run git --version in terminal. It'll either show the version of installed git or will ask if you want to install git together with other developer tools.
Install brew on Mac, install any of these on Windows. These are just package managers. Use them to install nvm.
Install nvm (it's node version manager, arguably the most convenient way to manage node.js installations) on both machines.
Use nvm to install node.js (npm comes bundled with it) on both machines. That's it! One-time set-up done. Run node -v && npm -v to check that both are installed.
Now, to start each project you would do the following:
Create a repo (which is like a folder but on GitHub/BitBucket server) that you may freely access from any device that has internet connection.
Start project on any of your machines with something like npm init or vue init webpack-simple or whatever you feel comfortable with.
Run git init
When you do changes, commit & push them into your online repo.
Avoid committing files that might be auto-regenerated, they simply don't worth storing.
You may use any npm commands.
When you want to continue working on another machine, simply git clone your existing repo, run npm install and you are done.
Commit changes if needed.
git pull changes to another device if needed
I have updated my asp.net core API over linux server using kestrel, I want to run the core application using pm2. Let me know if any buddy has already done this kind of task.
What I have tried is:
I Installed the pm2 on my linux server (not globally). It installed successfully but when I'm trying to run the code using pm2, I am getting error pm2, command not found
I tried to install the pm2 globally but getting write access issue in node modules some where but I can't give global write access.
Thanks in advance for your help :)
pm2, command not found means the binary is not found cause it is most probably missing in your PATH variable. The path differs whether you install it globally or not - see pm2-command-not-found how to figure out the path and how to add it to your PATH variable.
When not installed globally, the binaries are under ~\node_modules. This you have to add the actual binary path e.g. ~/node_modules/pm2/bin to the PATH variable or you call it directly using ~/node_modules/pm2/bin/pm2
For the installation problem mentioned above, run the installation as sudo npm install -g pm2
I am having problem using libraries installed on windows to WSL and vice versa. I don't want to install not just nodejs but other things twice just to use it in WSL and also in normal text editors like VS code, atom, etc.
The complete instruction can be found here set-up-on-wsl
If you are too busy to follow the link, follow these steps in the WSL:
Use curl to install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
For installing NodeJs (lts)
nvm install node --lts
You can also install specific node version. Check all commands uses by typing nvm in your terminal.
Done Node has been successfully installed in your WSL, nvm ls will list all the installations.
You can use the Node installed in your WSL for developing. Point to your working directory and use code . to open VSCode. Also, if you want to access your windows directories you can mount them by using /mnt/<dir>
If you face any issues during installation it is better to use the link I have provided above.
Also note that, the Node installed in the WSL can only be used, iff your working directory is in the WSL or is linked with your WSL(by using mnt).
I have a Python application in Openshift, with Python 3.3 and PostgreSQL cartridges. The Python cartridge is running Django 1.8, based off the template on the Website.
Recently, I started using Gulp to automate my build, and while it's worked great on my local machine, I can't figure out what to do to use it in Openshift. I have django-gulp installed so it just runs whenever I use runserver, but the Openshift server obviously doesn't have gulp or any plugins installed, so that won't do anything. I don't know how to install them on the server, though.
Including a package.json does nothing. I've tested it and it works fine if I go with a node cartridge, but I've got a Python one.
Since npm is on the server, I tried SSHing and running npm install manually, but it threw up a permission denied error.
So, after trying to work this out for a while, I've finally figured out a solution. This is a bit convoluted, but it does work:
Install your own Node and npm. The version included in Openshift is hopelessly outdated and doesn't really work. SSH into your server and install a local version in your dependencies folder. cd $OPENSHIFT_HOMEDIR/app_root/dependencies; wget https://nodejs.org/dist/v6.3.0/node-v6.3.0-linux-x64.tar.xz; tar xf node-v6.3.0-linux-x64.tar.xz; rm node-v6.3.0-linux-x64.tar.xz Install the dev version. DO NOT install the stable version as that'll burn through your inodes like nothing else.
Change your PATH to include the the new node version export PATH="$OPENSHIFT_HOMEDIR/app_root/dependencies/node_modules/.bin/:$OPENSHIFT_HOMEDIR/app_root/dependencies/node/bin/:$PATH" Environment variables get reset whenever you disconnect from the server. You can change them permanently with rhc env set, but as this is only used before deployment, I recommend sticking this in the /.openshift/action_hooks/pre_build.
You also need to change the NPM_CONFIG_USERCONFIG variable. export NPM_CONFIG_USERCONFIG=$OPENSHIFT_HOMEDIR/app-root/build-dependencies/.npmrc. Once again, I recommend doing this in the pre_build hook.
At this point, you can change the cache without getting a permission denied error. npm config set cache "$OPENSHIFT_HOMEDIR/app_root/dependencies/.npm
You can now finally use npm install! Install the packages you need. Use the --prefix flag to install to the node_modules folder.
However, to use gulp, you need to have a gulp module installed in the place you're calling from, so npm install gulp WITHOUT the prefix flag.
You can now call gulp! However, your gulpfile will not not find the modules unless you edit your gulpfile to link to the dependencies folder you have set up. So instead of require('gulp-cssnano'), you'd have require([OPENSHIFT_HOMEDIR]/app_root/dependencies/node_modules/gulp-cssnano). I keep a separate gulpfile for Openshift to maintain my sanity.
Call gulp with your new gulpfile in pre_build.