npm-如何安装gulp 4

我一直在用口水表。 当前版本的gulp-watch依赖于调用gulp.parrallel。 此呼叫仅在gulp 4中可用。

但是,gulp 4无法通过npm repo使用。npm info gulp dist-tags返回:npm install https://github.com/gulpjs/gulp#v4.0.0

我可以看到git repo中有一个4.0分支。 但是尝试使用以下命令的变体安装它失败:npm install https://github.com/gulpjs/gulp#v4.0.0

dave dave asked 2020-08-05T16:25:57Z
10个解决方案
31 votes
npm install gulpjs/gulp.git#4.0 --save-dev
Andor Lundgren answered 2020-08-05T16:25:59Z
29 votes

Gulp已从其GitHub存储库中删除了4.0分支,因此以前使用npm install gulp@next进行安装的方法不再起作用。

他们在自述文件中指出,安装gulp 4.0的正确方法是运行以下命令:

npm install gulp@next

syastrov answered 2020-08-05T16:26:25Z
23 votes
# Uninstall previous Gulp installation and related packages, if any
$ npm rm gulp -g
$ npm rm gulp-cli -g
$ cd [your-project-dir/]
$ npm rm gulp --save-dev
$ npm rm gulp --save
$ npm rm gulp --save-optional
$ npm cache clean # for npm < v5

# Install the latest Gulp CLI tools globally
$ npm install gulpjs/gulp-cli -g

# Install Gulp 4 into your project as dev dependency
$ npm install gulp --save-dev

# Check the versions installed. Make sure your versions are not lower than shown.
$ gulp -v
---
[10:48:35] CLI version 2.0.1
[10:48:35] Local version 4.0.0

详细信息在此博客页面上:[https://demisx.github.io/gulp4/2015/01/15/install-gulp4.html]

demisx answered 2020-08-05T16:26:45Z
15 votes

运行以下命令以检查计算机上安装的gulp cli的版本。

gulp -v

如果您没有运行版本4,请执行以下操作以在计算机上全局安装gulp。

npm uninstall -g gulp
npm install -g "gulpjs/gulp#4.0"

现在在本地安装gulp 4

npm uninstall gulp --save-dev
npm install "gulpjs/gulp#4.0" --save-dev
Thembelani M answered 2020-08-05T16:27:14Z
7 votes

2018年11月»npm审核运行:npm install --save-dev gulp@4.0.0

August answered 2020-08-05T16:27:34Z
2 votes

要安装gulp-4,CLI版本必须为1.2.2,才能支持gulp 4.0

安装gulp-cli 1.2.2运行npm install 'gulpjs/gulp.git#4.0' --save-dev

并安装gulp 4.0运行npm install 'gulpjs/gulp.git#4.0' --save-dev

当您运行gulp -v命令时

你应该得到

[11:38:36] CLI版本1.2.2

[11:38:36]本地版本4.0.0-alpha.2

GitHub上的类似问题

Rajath M S answered 2020-08-05T16:28:25Z
2 votes

我的安装有点不同。

跑步

npm install 'gulpjs/gulp.git#4.0' --save-dev

要么

npm install 'gulpjs/gulp#4.0' --save-dev

给我一个错误:

npm ERR! 代码EINVALIDTAGNAME npm ERR! 无效的标签名称“ gulp#4.0”:标签 可能没有任何编码URIComponent编码的字符。

注意:我在安装本地gulp-4时仅遇到问题,因此我查看了最后的package.json安装并看到了以下内容:

"gulp": "github:gulpjs/gulp#4.0",

所以我的举动是用

npm install "github:gulpjs/gulp#4.0" --save-dev

并且有效,成功安装了本地gulp 4。

[15:45:55] CLI version 1.4.0
[15:45:55] Local version 4.0.0-alpha.2
ArchNoob answered 2020-08-05T16:29:16Z
2 votes

从2018年12月28日开始,以下命令在本地安装版本4时可以正常工作。

npm i -D gulp
klewis answered 2020-08-05T16:29:37Z
1 votes

我写了一个批处理文件,该文件根据@demisx的回答完成了工作。

我遇到的问题是缺少npm config参数'prefix',所以我的全局目录是节点二进制目录。我可以肯定情况并非总是如此,但是我可以从项目根目录运行此脚本(重新设置):

@ECHO OFF
echo configuring npm
set USERNAME=<enter username>
set USERPROFILE=C:\Users\%USERNAME%
set APPDATA=%USERPROFILE%\AppData\Roaming
call npm config set prefix %APPDATA%\npm

SET DIR_PROJECT="D:/stuff/plugins/wallpaper_engine/raintime-dev"

echo Uninstall previous Gulp installation and related packages, if any
call npm rm gulp -g
call npm rm gulp-cli -g

echo cd %DIR_PROJECT%
cd /D %DIR_PROJECT%

call npm rm gulp --save-dev
call npm rm gulp --save
call npm rm gulp --save-optional
call npm cache clean

echo Install the latest Gulp CLI tools globally
call npm install gulpjs/gulp-cli -g

echo Install Gulp 4 into your project from 4.0 GitHub branch as dev dependency
rem call npm install gulpjs/gulp#4.0 --save-dev
call npm install gulpjs/gulp --save-dev

echo Check the versions installed.

call gulp -v

pause

脚本最终显示了这一点:

[14:59:48] CLI version 2.0.1
[14:59:48] Local version 4.0.0

希望能帮助到你!

Manticore answered 2020-08-05T16:30:10Z
0 votes

我通过运行解决了这个问题:

which gulp
rm -rf /usr/local/bin/gulp
npm i -g gulp
Jesus Sandrea answered 2020-08-05T16:30:31Z
translate from https://stackoverflow.com:/questions/33429727/how-do-i-install-gulp-4