简体   繁体   English

带角度节点或不使用angular-cli如何创建均值应用时出现问题

[英]Problems when bringing node with angular OR how to create a mean app without using angular-cli

I am using angular4. 我正在使用angular4。 I used angular-cli to create my project. 我使用angular-cli创建了我的项目。

I want to use node.js as server side language with mongodb. 我想将node.js用作mongodb的服务器端语言。 So, I found a tutorial here to connect node.js with angular. 因此,我在这里找到了一个将angular.node.js连接起来的教程。

But there are two problems with it: 但是它有两个问题:

  1. dist folder is created. dist文件夹已创建。
  2. auto refresh server like using nodemon or similar is lost 像使用nodemon或类似的自动刷新服务器丢失

problem with dist folder dist文件夹有问题

My site depends heavily on images. 我的网站在很大程度上取决于图像。 I keep all the images in a folder called images which is located under assets folder created by angular-cli 我将所有图像保存在名为images的文件夹中,该文件夹位于由angular-cli创建的资产文件夹下

So, when I run the server, all the assets will be copied to the dist directory, which will take time and (more important) space on the webserver. 因此,当我运行服务器时,所有资产都将被复制到dist目录,这将花费时间和网络服务器上(更重要的是)空间。 Another problem is that If I upload new images, then it will be copied to the images folder inside dist folder, so I have to manually copy those images to my original dist folder. 另一个问题是,如果我上传新图像,则它将被复制到dist文件夹内的images文件夹中,因此我必须手动将那些图像复制到我的原始dist文件夹中。

Another copy of images folder in dist folder will take double space than my original app. dist文件夹中images文件夹的另一个副本将比我原来的应用占用两倍的空间。 So, I have to pay more money for hosting to use more space. 因此,我必须为托管使用更多空间而花更多的钱。

problem with auto-refresh server 自动刷新服务器的问题

before using node, I just typed this command 在使用节点之前,我只是键入了此命令

ng serve

and my application started. 然后我的应用程序启动了。 Then when I change any code and save the file, the changes were reflected in the browser without restarting the server. 然后,当我更改任何代码并保存文件时,更改将反映在浏览器中,而无需重新启动服务器。

But when I started to use node, I have to manually restart the server whenever I make changes to my code. 但是,当我开始使用节点时,只要更改代码,就必须手动重新启动服务器。

Question: 题:

Is there any way that prevents app to create images folder inside dist folder to save space. 有什么办法可以防止应用程序在dist文件夹内创建图像文件夹以节省空间。 I mean can I use original Images folder instead of creating one inside dist? 我的意思是可以使用原始Images文件夹而不是在dist中创建一个吗?

Or is there any other way that a node application and angular application work together? 还是节点应用程序和角度应用程序可以协同工作的其他方式?

If anybody knows a solution that does not use dist folder, then I would love to use that solution. 如果有人知道不使用dist文件夹的解决方案,那么我很乐意使用该解决方案。 As my need is satisfied. 由于我的需要得到满足。 Auto-refresh server is not important to me in this case. 在这种情况下,自动刷新服务器对我而言并不重要。

So, if anybody knows a way of how to create a mean app without angular-cli, then I think that is very near to my solution. 因此,如果有人知道如何在没有angular-cli的情况下创建平均应用的方法,那么我认为这与我的解决方案非常接近。

You can change dist folder's name to any name you want. 您可以将dist文件夹的名称更改为所需的任何名称。 you just need to find file .angular-cli.json in your main root folder and change json 您只需要在主根文件夹中找到文件.angular-cli.json并更改json

"apps": [
    {
      ...,
      "outDir": "dist", // dist to any name e.g. public, ...
      ...
   }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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