【发布时间】:2018-07-09 09:26:09
【问题描述】:
我的机器经常出现奇怪的问题。每次我安装一些新的 npm 依赖项时,gulp 都会神奇地从 node_modules 文件夹中消失。
gulp 目前作为 devDependency 安装为:"gulp": "github:gulpjs/gulp"
如果我发出通常的npm install 一切都会恢复正常
非常清楚:
$ npm install github:gulpjs/gulp --save-dev
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
+ gulp@4.0.0
added 183 packages in 26.452s
然后如果我尝试安装新的东西...
$ npm install eyeglass --verbose
npm info it worked if it ends with ok
npm verb cli [ '/Users/peach/.nvm/versions/node/v8.11.3/bin/node',
npm verb cli '/Users/peach/.nvm/versions/node/v8.11.3/bin/npm',
npm verb cli 'install',
npm verb cli 'eyeglass',
npm verb cli '--verbose' ]
npm info using npm@5.6.0
npm info using node@v8.11.3
npm verb npm-session 48e35d62250ec820
npm http fetch GET 200 https://registry.npmjs.org/eyeglass 15ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/ensure-symlink 20ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/archy 22ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/deasync 21ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/lodash.includes 20ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/fs-extra 21ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/lodash.merge 24ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/node-sass-utils 25ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/bindings 3ms (from cache)
npm verb correctMkdir /Users/peach/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /Users/peach/.npm/_locks/staging-89e2cc30db562072.lock for /Users/peach/repos/sotb-six/node_modules/.staging
npm info lifecycle gulp@4.0.0~preuninstall: gulp@4.0.0
npm info lifecycle gulp@4.0.0~uninstall: gulp@4.0.0
npm verb unbuild rmStuff gulp@4.0.0 from /Users/peach/repos/sotb-six/node_modules
npm info lifecycle gulp@4.0.0~postuninstall: gulp@4.0.0
...
+ eyeglass@1.5.0
removed 183 packages and updated 1 package in 10.707s
npm verb exit [ 0, true ]
npm info ok
接下来是很多其他的包删除...
不知道发生了什么,我很不幸试图为此找到解决方案
使用npm@5.6.0 和node@v8.11.3
[edit] 尝试删除 package-lock.json 并重新安装 gulp,然后分别安装 $whateverpackage,但结果相同。
$ rm package-lock.json
$ npm install github:gulpjs/gulp
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
+ gulp@4.0.0
added 183 packages in 32.953s
$ ls -l node_modules/.bin/gulp
lrwxr-xr-x 1 peach staff 19 Jul 9 13:24 node_modules/.bin/gulp -> ../gulp/bin/gulp.js
$ npm install eyeglass
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
+ eyeglass@1.5.0
removed 183 packages and updated 1 package in 12.959s
$ ls -l node_modules/.bin/gulp
ls: cannot access 'node_modules/.bin/gulp': No such file or directory
【问题讨论】:
-
node_modules/gulp还在吗? -
不。它被完全卸载了。 (它是被删除的 183 个软件包的一部分)
-
到目前为止我发现: • 使用 npm 6.1 而不是 5.6 时有效 • 使用
npm install eyeglass --save时有效 • 使用npm install eyeglass --no-dev时有效 您能确认这些发现吗?跨度> -
@RaphaelSchweikert 可以确认,npm 5* 将被删除,6 保持 gulp,无论选项如何(不带选项运行并且按预期工作)。
-
是的,npm 6 可以正常工作,但对我来说,5.6 也可以(至少有时)使用这些选项。
标签: node.js npm gulp npm-install