简体   繁体   English

是否有最低版本的“ npm install grunt”?

[英]Is there a minimal version of “npm install grunt”?

When I run npm install grunt I get, in my opinion, a heavily polluted project folder. 我认为,当我运行npm install grunt时,会得到一个污染严重的项目文件夹。 In the folder node_modules there are libs like rimraf, coffescript and others I really don't want to use. 在node_modules文件夹中,有rimraf,coffescript之类的库,还有其他我真的不想使用的库。 Are these required for grunt itself to be able to run or are they only there for my convenience? 这些是咕gr声本身运行所必需的,还是仅在我方便时存在?

I would like some kind of "npm install grunt --minimal" to only install an absolute minimum of what's needed to be able to use grunt. 我希望某种“ npm install grunt --minimal”仅安装能够使用grunt所需的绝对最小数量。 I don't really like my project folder full of stuff that's not really my own code. 我真的不喜欢我的项目文件夹中充满的东西不是我自己的代码。 I've googled the terms i can come up with, like "minimal grunt install", but only found the basic install tutorials. 我已经搜索了我可以想到的术语,例如“最小安装”,但只找到了基本的安装教程。

Create a node_modules directory in a directory above your project's directory and do npm install grunt there. 在项目目录上方的目录中创建一个node_modules目录,并在此处执行npm install grunt That way the modules are accessible but they aren't in your project's node_modules directory. 这样就可以访问模块,但是它们不在项目的node_modules目录中。

Another option is to use npm install -g grunt to install grunt globally. 另一种选择是使用npm install -g grunt grunt全局安装grunt。

No, you can not. 你不能。 Grunt is npm package and it has dependencies (this is normal). Grunt是npm软件包,它具有依赖关系(这是正常的)。 The fact is this dependencies don't pollute your project folder structure. 事实是,这种依赖关系不会污染您的项目文件夹结构。 It is normal to 这是正常的

  • add node_modules to .gitignore and don't commit it 将node_modules添加到.gitignore,不要提交

  • install every npm package with --save flag (will write package to package.json) or --save-dev flag (will write package to package.json as package needed for development) 使用--save标志(将程序包写入package.json)或--save-dev标志(将程序包写入package.json作为开发所需的软件包)安装每个npm软件包

  • commit package.json to repository. 将package.json提交到存储库。 Thus, every team member can install all packages via npm install or npm install --production 因此,每个团队成员都可以通过npm installnpm install --production安装所有软件包。

As Dan said you can install grunt globally with -g flag but this will not solve your problem as every npm package that you install will have it own dependencies (and you'll probably think that it pollutes you folder structure as well) 正如Dan所言,您可以使用-g标志在全局范围内安装grunt,但这不能解决您的问题,因为您安装的每个npm软件包都具有自己的依赖关系(而且您可能会认为它也会污染文件夹结构)

You know, there are a lot of things that you need for development (or production). 您知道,开发(或生产)需要很多东西。 While installing apache (or something else) you don't say that is pollutes your file system (but it has own folder and so on). 在安装apache(或其他)时,您不会说这会污染您的文件系统(但它具有自己的文件夹,依此类推)。

Things don't pollute file structure if they don't exist in your project repository. 如果项目存储库中不存在事物,则它们不会污染文件结构。

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

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