Exporting my Node.JS website for deployment

问题内容:

I am trying to export a version of my project without all the unnecessary node modules that come in the node_modules folder.

For the first time I am developing a website using node.js. I used it to include Bootstrap and jQuery, as well as compiling my sass stylesheet.

Now I want to upload it to the server through FTP, but the host does not support Node.Js. Therefore I want to ‘compile’ a version that does not require Node.js.

Currently when I try to upload the whole project, I am uploading a couple of thousand, but it’s just a small website.

This is my package.json:-

{
  "name": "veerman",
  "version": "1.0.0",
  "description": "Veerman Assurantien pkg",
  "main": "init.js",
  "watches": {
    "sass": "styles/**"
  },
  "scripts": {
    "sass": "node-sass styles/ -o dist/css/ --output-style compressed",
    "dev": "rerun-script"
  },
  "repository": {
    "type": "git",
    "url": "Veerman Assurantien"
  },
  "author": "Demiën Drost",
  "license": "ISC",
  "dependencies": {
    "bootstrap": "^3.3.7",
    "jquery": "^3.2.1",
    "normalize.css": "^7.0.0"
  },
  "devDependencies": {
    "node-sass": "^4.6.1",
    "rerun-script": "^0.6.0"
  }
}

So, I want to ‘build’ the project to be able to run on it’s own without all the other junk.

问题评论:

    
So publish just those files. What’s the problem?
    
One of the lines in your json above references dist/ – perhaps that’s the directory you’re looking for.
    
What does your init.js look like? Please paste the code.
    
@SLaks I don’t want to publish the website to NPM. @JamesThorpe The only content of dist/ is the compiled sass file. @maxpaj init.js doesn’t hold any contents.
– Demiën Drost
1 hour ago
1  
If your host doesnt support node thet you will have to use some other language like php or change host

答案:

答案1:

Depending on how your init.js is written you should be able to do this. I’d test it via running your build command/step, then using something like http-server to verify you don’t need any of the nodejs stuff. Just CD to the dist/ folder, run http-server . and then goto the url listed in the console.


If that’s all great, upload the contents of dist/

答案评论:

    
My init.js file is completely empty. And on executing the command npm build it only prints a blank line. Therefor the only contents of my dist/ folder is my compile sass file, which I put there through the dev script.
– Demiën Drost
1 hour ago
    
This answer is wrong.

原文地址:

https://stackoverflow.com/questions/47755405/exporting-my-node-js-website-for-deployment

添加评论

友情链接:蝴蝶教程