如何将Gulp添加到我的项目中? [英] How to add Gulp to my project?

查看:127
本文介绍了如何将Gulp添加到我的项目中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows 7,Visual Studio 2013.我试图在我的客户端项目中设置Gulp。

I'm using Windows 7, Visual Studio 2013. I'm trying to set up Gulp in my Client's project.

我已经将这些Nugets添加到项目:
Node.js版本0.12.0
Npm.js版本1.3.15.10。

I've added those Nugets to the project: Node.js version 0.12.0 Npm.js version 1.3.15.10.

由于某些原因,我不知道,何时在默认项目是客户端时,在nuget软件包管理器中运行 npm init ,它不会创建package.json文件,也不会询问关于该文件的问题,并且命令从来没有退出。

For some reason I don't know, when running npm init inside the nuget package manager when the default project is the client, it is not creating a package.json file, no question are asked regarding the file, and the command never exits.

这是否与我只通过Visual Studio项目工作的事实有关?后来我通过安装程序下载了Node.js,因为我的电脑上没有看到node.js的版本。

Is this related somehow to the fact that I only worked through the Visual Studio project? Later on I downloaded Node.js through the installer because I saw no version of node.js existed on my pc.

我是否需要在Visual Studio之外安装npm?我没有访问网络,我应该得到一个.msi文件吗?

Do I need to install npm also outside of Visual studio? I don't have access to the network there, should I get an .msi file?

关于Gulp nuget包,我已经在其他网站上读到过,应该使用以下命令通过npm安装Gulp: npm install gulp -g -save dev 。我无法运行该命令,因为我没有网络连接,因此我怎么才能用gulp nuget包来做到这一点?

Regarding the Gulp nuget package, I've read in other sites that Gulp should be installed through npm using this command: npm install gulp -g -save dev. I can't run that command because I have no network connection, therefore how can I do that only with the gulp nuget package?

请帮我理解需要什么步骤来获取node.js,npm,最后Gulp正在运行

Please help me understand what steps are needed to get node.js, npm, and finally Gulp running

推荐答案

我不知道交易与 npm init 是什么,但我的第一个建议是尝试更新版本的npm - 当前版本是3.9.6;如果您使用更新的版本,我怀疑您会有更好的时间。一般而言,npm和节点旨在全局安装,而不是单个软件包;我对nuget了解不多,但也可能会造成麻烦(我想如果你在本地安装npm,你应该可以很好地使用它,但是,像 ./ node_modules /。 bin / npm init --yes ,这就是我列出它的原因)。您可以让msi安装此处,但我收集你没有网络访问。如果这不起作用,您可以相当容易地手动创建 package.json ,它会和自动生成的一样好 - 这里 a> 一些 合理的 示例。您也可以考虑提交 npm问题

I don't know what the deal is with npm init, but my first suggestion is to try a newer version of npm -- the current version is 3.9.6; I suspect you'll have a better time if you use a more up-to-date version. Generally, npm and node are intended to be installed globally, and not for a single package; I don't know a lot about nuget, but that may also be causing trouble (I think if you install npm locally, you should be able to use it just fine, though, like ./node_modules/.bin/npm init --yes, which is why I list it second). You can get the msi to install the lts release of both here, though I gather you don't have network access. If that doesn't work, you can create a package.json by hand fairly easily, and it'll be just as good as the auto-generated one -- here are some reasonable examples. You might also consider filing an issue with npm.

至于如果无法运行 npm i -g ,如何安装gulp,它比您期望的更容易解决。本地安装的gulp与本地安装的gulp没有区别,当您访问它们时,它们只使用两种不同的脚本。当 require(gulp)时,您会看到 main ,当您在命令行运行 gulp 时,您会看到 bin ,并且都包含在本地和全局安装中(您可以查看 gulp's package.json 了解更多详情)。因此,对于全局安装而言意味着您只需要获取gulp的bin文件( node_modules / gulp / bin / gulp.js node_modules /的.bin /一饮而尽,它指向 node_modules /一饮而尽/斌/ gulp.js )以某种方式(可以只需将脚本复制到路径上的文件夹,但它需要node_modules文件夹中的所有其他内容才能工作),或者可以直接从本地安装中调用bin脚本(我是Linux用户,所以我会像这样运行 compile 任务: ./ node_modules / .bin / gulp compile - 我不会不知道如何使用Windows,所以我希望能让你足够接近)。

As to what to do to install gulp if you can't run npm i -g, it is easier than you might expect to work around. There is no difference between the gulp that is installed locally and the gulp that is installed locally, they just use two different scripts when you access them. When you require("gulp"), you get the script listed in main, and when you run gulp at the command line, you get the script listed in bin, and both are included in both a local and global install (you can look at gulp's package.json for more details). So, what that means for a global install is that all you need to do is get gulp's bin file (node_modules/gulp/bin/gulp.js, or node_modules/.bin/gulp, which points to node_modules/gulp/bin/gulp.js) on your PATH somehow (you can't just copy the script to a folder on your path, though, it needs all the other things from its folder in node_modules to work too), or you can call the bin script from your local install directly (I'm a linux user, so I'd run the compile task like this: ./node_modules/.bin/gulp compile -- I don't know how to Windows, so I hope that gets you close enough).

这篇关于如何将Gulp添加到我的项目中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆