I have Created a new angular project and converted it to universal. After running npm run build:ssr i got file structure like this
dist
----my-project
---browser
---server
and when i run command npm run serve:ssr my server is running on port localhost:4000 but now i want to host my project on my siteground hosting server where i uplaod my dist folder file (browser and server) using filezila, but i got an error 404 then i upload package.json file and connect through ssh to my terminal and install first node after that i put command npm install on derectory where i have upload all file with package.json but again i am fail. please if any one have idea to help me.
Related
I am new to using Node.js
I have a project folder structure C:\A\B\C\
I have C:\A\B\C\html_pages\index.html in which I have React.js code having CDN
and C:\A\B\C\server.js which has Express.js code which I want to run.
I installed nvm then installed Node.js using command
nvm install 4.5
In windows PowerShell, I went to project directory
C:\A\B\C and used npm init (node_modules were not created in this step)
Did npm install express --save to use the express module (now node_modules folder was created but package.json was inside express folder)
Used npm start to start the web server but it gave following error.
ENOENT: no such file or directory, open 'C:\A\B\C\package.json'
I checked the posts on Stackoverflow for this error but was not able to solve it.
Should the package.json be generated directly under 'C:\A\B\C\ ?
I have installed Node.js in C:\Program Files\nodejs while project is not under Program Files, is this related to this?
P.S. : Used npm init --yes so that it installs node_modules inside my project folder and got the request processed but port 3000 gives error that it did not get GET request
The package.json file should be on the root of your directory.
Open command line from your root directory and type,
npm init
This will generate a package.json file on that directory.
I am having a npm package which serves as a local host. What I want is after user use npm install -g to install it, they can use the command easydx to run the local host and web pages can be served as in a static server.
During development, it works fine with npm start and the pages can successfully open at localhost:3666. But when I publish the package and tested it using npm install -g to install it. After easydx successfully fires the server, localhost:3666 get the cannot get / error.
My package contains the line:
"bin": {
"easydx": "index.js"
},
and my index.js file begins with
#! /usr/bin/env node
So what is going wrong here?
In my index.js file:
I have used:
app.use(express.static('dist'));
to serve the static web files. And have used express routes for the web service.
I downloaded the starter kit for react and redux. It's really nice and works fine in localhost with the command npm run dev but I'm not able to deploy it on the server.
First, I use the command npm run deploy which clean and compile my src folder in the dist folder. Then, I deploy the server on Heroku. Once all is built, the server run npm start which execute the command babel-node bin/server. This command is not recognized by the heroku server.
I would really appreciate if someone could help me to debug this. I tried to clone again the repo, then :
npm install
npm run deploy
Publish on Heroku and I have the same error without changing anything on the code.
The reason it doesn't work on heroku is because there isn't any production server ready in this project for your deployment as specified here : https://github.com/davezuko/react-redux-starter-kit#deployment
When you run the npm run deploy command, all the front-end code is compiled in the /dist folder.
In order to deploy it on heroku you need to :
Create a very simple http server always serving the file index.html. Here is the main part using Express or Koa
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/dist/index.html'));
});
Modifying the npm start script in order to target this new production ready server.
I have installed npm and node on localhost using command terminal. I can view my nodejs app after entering command npm start in the command prompt and going to address http://localhost:3000. Now, I have to upload this setup to live server. What folders do I need to move to the server and what commands should i execute to make it work on live server?
except node_modules you have to upload the necessary files and folders. In server try npm install.
I can't deploy my ExpressJS app to Heroku or OpenShift hosting. On my MacBook Pro all works perfectly, but it go to crash when I try to deploy it on hosting.
error Error: shasum check failed for /app/tmp/npm-403-gj-8PMyB/1387967953013-0.7812028499320149/tmp.tgz
344 error Expected: f99cd60b91df7e6669c59ac2b55c4bfc65ff9494
344 error Actual: c4a5f6cf7f807d89d1aa0babe686b434426206b6
openshift log, heroku log
I had the same problem on Heroku before that I did not figure out what caused it.But this is how I fixed mine:
first remove the dependency (in your case it could be process-pwd ) from package.json file
open the terminal app on your mac and go to you project folder
run the install command for the package that fails
npm install moduleName
this will install a local copy of the module in your project folder inside node_modules folder
deploy the app again
Hope this works but you have to figure out which module actually fails :)