Reputation: 209
this is folder structure I have a npm installed folder, when i copy that folder and run on desktop its not working. I use npm run ds to run server and view the website.
my desktop doesnot have npm. What is the procedure to install npm folder and run the react.js website?
Upvotes: 1
Views: 3447
Reputation: 151
Setup React.js Environment Using Npm simple hello world
1.mkdir foldername
2.cd foldernmae
3.npm init
Installing and Configuring Webpack npm i webpack -S
touch webpack.config.js
Update the config file as follows
var webpack = require('webpack');
var path = require('path');
var BUILD_DIR = path.resolve(__dirname, 'src/client/public');
var APP_DIR = path.resolve(__dirname, 'src/client/app');
var config = {
entry: APP_DIR + '/index.jsx',
output: {
path: BUILD_DIR,
filename: 'bundle.js'
}
};
module.exports = config;
then create the index,js file and in the ./src/client/app , add the following code console.log('Hello World!');
Now in the terminal run the following command
./node_modules/.bin/webpack -d
Upvotes: 1
Reputation: 15642
"my desktop doesnot have npm"
Probably you do not have Node.js either.
Well, to start with, install Node.js first. You will need Node.js to run JavaScript on your desktop.
Windows:
Download .msi
installer from here https://nodejs.org/en/download/
Debian/Ubuntu:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
For any other OS, the steps are explained here https://nodejs.org/en/download/package-manager/
If you follow the above procedures, npm (Node Package Manager) is also automatically installed on your system.
Now if you run node -v
you will see the installed Node.js version.
Similarly npm -v
shows your current npm
version.
After this, you can go to your project folder and run npm install
.
npm install
inside a folder will scan through package.json
and install all dependencies locally.
Refer your package.json
"scripts",
"scripts": {
"start": "NODE_ENV=development webpack-dev-server --inline --content-base"
...
}
If you have something like this, then run npm run start
to start your App.
Upvotes: 0
Reputation: 1844
goto Desktop using terminal/cmd prompt and execute npm install
Upvotes: 0