简体   繁体   English

这是 Node.js 项目的通用文件夹结构吗?

[英]Is this a common Folder structure for a Node.js project?

I am continuing on a project that someone else started it before, and I was still a beginner in nodejs when i first started with him, but after acquiring some experience and seen enough tutorials, I am finding his project's folder structure a bit strange, I haven't seen anything like it in the online tutorials.我正在继续一个别人之前开始的项目,当我第一次开始使用他时我还是 nodejs 的初学者,但是在获得了一些经验并看过足够多的教程之后,我发现他的项目的文件夹结构有点奇怪,我在在线教程中没有看到类似的东西。

Is the below a common practice in node.js projects, and if yes, why the root project folder is inside a folder named node_modules?以下是 node.js 项目中的常见做法,如果是,为什么根项目文件夹位于名为 node_modules 的文件夹中? node_modules is usually for storing the npm packages. node_modules 通常用于存储 npm 包。

 └───node
        └───node_modules <---Why?
            └───project
                ├───backoffice
                │   └───client
                │       ├───controllers
                │       ├───css
                │       └───views
                ├───common
                ├───frontoffice
                │   └───client
                │       ├───controllers
                │       ├───css
                │       └───views
                ├───models
                └───node_modules

I think that this file structure is, not just a bit but very strange, I'm not a professional, but I've worked a lot on node.js projects (all by my on), and I already see a lot of node.js projects from other people.我觉得这个文件结构,不只是有点,而且很奇怪,我不是专业的,但是我在node.js项目上做了很多工作(都是我自己的),我已经看到很多node .js 项目来自其他人。

So I would say that this folder structure is really messed up.所以我会说这个文件夹结构真的很混乱。 Commonly the root directory is a folder with the project's name, without special characters (including spaces), the node_modules folder is a folder JUST for node packages and it's created automatically by node when you run "npm install" for some package.通常根目录是一个带有项目名称的文件夹,没有特殊字符(包括空格),node_modules 文件夹是一个只用于节点包的文件夹,它是当你为某个包运行“npm install”时由节点自动创建的。

For the project files, it's more common to create a source folder in the root directory (src).对于项目文件,更常见的是在根目录 (src) 中创建源文件夹。 I think that's a good practice, mainly if you have a lot of configuration files.我认为这是一个很好的做法,主要是如果您有很多配置文件。

I hope this helps!我希望这有帮助!

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

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