简体   繁体   中英

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

  1. Install NodeJS
  2. Open Command Line
  3. Make a new folder under your user folder called test mkdir test
  4. cd into that folder on Windows Command Line cd test
  5. Create a new project with npm init -y *note this creates a package.json file for you
  6. 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 )

Iam doing same like this

  1. install node.js and build an app
  2. i make api and run it on xammp
  3. i test xammp hosted api from postmna its working fine

Peoblem is that when i add xammp hosted api in my app it show me white page(noting show) anybody help me to out of this ScreenShot is attached no error in console [ https://i.stack.imgur.com/mJ6vu.png][1]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM