【发布时间】:2020-07-31 01:11:41
【问题描述】:
我将 Gulp.js v4 添加到项目的依赖项中并运行 yarn install --no-bin-links 以在本地安装。
$ yarn install --no-bin-links
yarn install v1.17.3
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.12: The platform "linux" is incompatible with this module.
info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 32.48s.
(我使用--no-bin-links参数来避免这个错误:error An unexpected error occurred: "EPROTO: protocol error, symlink '../../../semver/bin/semver' -> '/path/to/project/public/components/accord/node_modules/.bin/semver'"。)
package.json 定义了正确的版本范围:
{
...
"dependencies": {
"bootstrap": "^3.3.6",
"gulp": "^4.0.2",
"gulp-autoprefixer": "*",
"gulp-cli": "^2.2.0",
"gulp-filter": ">=6.0.0",
"gulp-less": "*",
"gulp-plumber": "*",
"gulp-rename": "*",
"gulp-watch": "*",
"html5shiv": ">=3.7.3",
"jquery": "^3.4.0",
"jquery-ui": "^1.12.1",
"jquery-ui-dist": "^1.12.1",
"path": "*",
"respond": ">=0.9.0"
},
...
}
yarn.lock 也指正确的版本:
...
gulp@^4.0.2:
version "4.0.2"
...
gulp-cli@>=2.2.0, gulp-cli@^2.2.0:
version "2.2.0"
...
yarn list 也提供了预期的输出:
$ yarn list | grep "gulp"
├─ gulp-autoprefixer@7.0.1
├─ gulp-cli@2.2.0
│ ├─ gulplog@^1.0.0
├─ gulp-filter@6.0.0
├─ gulp-less@4.0.1
├─ gulp-plumber@1.2.1
├─ gulp-rename@2.0.0
├─ gulp-watch@5.0.1
├─ gulp@4.0.2
│ ├─ gulp-cli@^2.2.0
├─ gulplog@1.0.0
但是当我现在执行 gulp 时,旧版本(使用 Gulp 3.9.1 和 Gulp CLI 1.2.1:
$ ./public/components/gulp/bin/gulp.js -v
[15:42:30] CLI version 1.2.1
[15:42:30] Local version 3.9.1
这里出了什么问题以及如何使用 Yarn 在本地正确安装所需的 Gulp 版本并使这个版本可以使用?
【问题讨论】:
标签: node.js npm gulp node-modules yarnpkg