如何将 Gulp 添加到我的项目中?
How to add Gulp to my project?
我正在使用 Windows 7,Visual Studio 2013。我正在尝试在我的客户项目中设置 Gulp。
我已将这些 Nuget 添加到项目中:
Node.js 版本 0.12.0
Npm.js 版本 1.3.15.10.
出于某种原因我不知道,当默认项目是客户端时 运行ning npm init
在 nuget 包管理器中时,它不会创建 package.json 文件, 没有关于文件的问题,命令永远不会退出。
这是否与我只完成了 Visual Studio 项目有关?后来我通过安装程序下载了 Node.js,因为我发现我的电脑上没有 node.js 的版本。
我是否还需要在 Visual studio 之外安装 npm?我无法访问那里的网络,我应该获取 .msi 文件吗?
关于 Gulp nuget 包,我在其他网站上了解到 Gulp 应该使用以下命令通过 npm 安装:npm install gulp -g -save dev
。我无法 运行 该命令,因为我没有网络连接,因此我如何仅使用 gulp nuget 包来执行该命令?
请帮助我了解获得 node.js、npm 和最终 Gulp 运行ning
需要哪些步骤
该命令似乎 运行 无限,因为您没有提供任何响应。 npm init
命令是交互式的,只有在您为每个输入请求提供响应后才会继续。
This will ask you a bunch of questions, and then write a package.json for you.
如果您想使用 package.json
的默认配置,您可以 运行 npm init -y
代替。
If you invoke it with -f, --force, -y, or --yes, it will use only defaults and not prompt you for any options.
我不知道 npm init
是怎么回事,但我的第一个建议是尝试更新版本的 npm -- 当前版本是 3.9.6;我怀疑如果您使用更新的版本,您会玩得更开心。通常,npm 和 node 旨在全局安装,而不是单个包;我对 nuget 了解不多,但这也可能会造成麻烦(我认为如果你在本地安装 npm,你应该可以很好地使用它,比如 ./node_modules/.bin/npm init --yes
,这就是我列出的原因第二)。您可以获得 msi 来安装 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.
的 lts 版本
至于如何安装 gulp 如果你不能 运行 npm i -g
,它比你想象的更容易变通。本地安装的gulp和本地安装的gulp没有区别,只是访问时使用了两个不同的脚本。当您 require("gulp")
时,您会获得 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 中列出的脚本以获取更多详细信息)。因此,这对于全局安装意味着您需要做的就是获取 gulp 的 bin 文件(node_modules/gulp/bin/gulp.js
或 node_modules/.bin/gulp
,它指向 node_modules/gulp/bin/gulp.js
)以某种方式在你的 PATH 上(你不能只将脚本复制到你路径上的文件夹,但是,它需要它在 node_modules 中的文件夹中的所有其他东西才能工作),或者你可以从调用 bin 脚本您直接在本地安装(我是 linux 用户,所以我 运行 compile
任务是这样的:./node_modules/.bin/gulp compile
-- 我不知道如何 Windows,所以我希望这能让你足够接近)。
我正在使用 Windows 7,Visual Studio 2013。我正在尝试在我的客户项目中设置 Gulp。
我已将这些 Nuget 添加到项目中: Node.js 版本 0.12.0 Npm.js 版本 1.3.15.10.
出于某种原因我不知道,当默认项目是客户端时 运行ning npm init
在 nuget 包管理器中时,它不会创建 package.json 文件, 没有关于文件的问题,命令永远不会退出。
这是否与我只完成了 Visual Studio 项目有关?后来我通过安装程序下载了 Node.js,因为我发现我的电脑上没有 node.js 的版本。
我是否还需要在 Visual studio 之外安装 npm?我无法访问那里的网络,我应该获取 .msi 文件吗?
关于 Gulp nuget 包,我在其他网站上了解到 Gulp 应该使用以下命令通过 npm 安装:npm install gulp -g -save dev
。我无法 运行 该命令,因为我没有网络连接,因此我如何仅使用 gulp nuget 包来执行该命令?
请帮助我了解获得 node.js、npm 和最终 Gulp 运行ning
需要哪些步骤该命令似乎 运行 无限,因为您没有提供任何响应。 npm init
命令是交互式的,只有在您为每个输入请求提供响应后才会继续。
This will ask you a bunch of questions, and then write a package.json for you.
如果您想使用 package.json
的默认配置,您可以 运行 npm init -y
代替。
If you invoke it with -f, --force, -y, or --yes, it will use only defaults and not prompt you for any options.
我不知道 npm init
是怎么回事,但我的第一个建议是尝试更新版本的 npm -- 当前版本是 3.9.6;我怀疑如果您使用更新的版本,您会玩得更开心。通常,npm 和 node 旨在全局安装,而不是单个包;我对 nuget 了解不多,但这也可能会造成麻烦(我认为如果你在本地安装 npm,你应该可以很好地使用它,比如 ./node_modules/.bin/npm init --yes
,这就是我列出的原因第二)。您可以获得 msi 来安装 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.
至于如何安装 gulp 如果你不能 运行 npm i -g
,它比你想象的更容易变通。本地安装的gulp和本地安装的gulp没有区别,只是访问时使用了两个不同的脚本。当您 require("gulp")
时,您会获得 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 中列出的脚本以获取更多详细信息)。因此,这对于全局安装意味着您需要做的就是获取 gulp 的 bin 文件(node_modules/gulp/bin/gulp.js
或 node_modules/.bin/gulp
,它指向 node_modules/gulp/bin/gulp.js
)以某种方式在你的 PATH 上(你不能只将脚本复制到你路径上的文件夹,但是,它需要它在 node_modules 中的文件夹中的所有其他东西才能工作),或者你可以从调用 bin 脚本您直接在本地安装(我是 linux 用户,所以我 运行 compile
任务是这样的:./node_modules/.bin/gulp compile
-- 我不知道如何 Windows,所以我希望这能让你足够接近)。