gulp-install不能安装与乙烯基文件的依赖关系
问题描述:
我是gulp插件的初学者。我想通过合并package.json来安装依赖关系。代码如下。gulp-install不能安装与乙烯基文件的依赖关系
gulp.task('install-dependencies', function() {
var through = require('through2');
var npm = require('npm');
var Promise = require('bluebird');
var file = require('gulp-file');
var install = require('gulp-install');
var path = require('path');
var npmLoad = Promise.promisify(npm.load);
var plugins = {};
//for test
var lastFile;
gulp.src([`${PATH.plugin}**/package.json`])
.pipe(through.obj(function parse_plugins(file, enc, cb) {
if (file.isNull()) {
cb();
return;
}
if (file.isStream()) {
this.emit('error', new gulpUtil.PluginError('package-concat', 'Streaming not supported'));
cb();
return;
}
let fileContent = {};
try {
fileContent = JSON.parse(file.contents.toString())
} catch (e) {
this.emit('error', new gulpUtil.PluginError('package-concat', `file '${file.path}' not a json file!`));
throw e;
}
plugins = Object.assign({}, plugins, fileContent.dependencies)
lastFile = file;
cb();
},
function install(cb){
let fileContent = {};
fileContent.name = "test";
fileContent.dependencies = plugins;
var file = new gulpUtil.File({
base: path.join(__dirname, './'),
cwd: __dirname,
path: path.join(__dirname, './package.json'),
contents: new Buffer(JSON.stringify(fileContent))
});
this.push(file);
cb();
}
))
.pipe(install());
})
但是,依赖项不按预期安装。日志如下。
[14时50分37秒]启动 '安装依存关系' ......
[14时50分37秒]结束后205毫秒 '安装依存关系'
NPM WARN可选跳绳失败可选的依赖/ chokidar/fsevents:
NPM WARN notsup不与您的操作系统或架构兼容:[email protected]
答
是什么你的操作系统?
您可能会发现类似here。
听起来像你可以尝试卸载一切,并从头开始(或者只是删除你的node_module文件夹,并使用npm安装)。但不确定,根据错误本身,您的操作系统很大程度上取决于您的操作系统。
操作系统:win10,节点:v5.9.1,npm:3.8.7 – user2530403
请点击这里:https://github.com/npm/npm/issues/12185 目前没有答案,但可能会有一个是我正在打字或在几天内... 您是否尝试删除** node_module **文件夹,然后运行'npm install'? – kazu
'npm install'只需安装我的devDependencies和核心依赖关系。当收集并合并package.json的一部分时,其他依赖项将由gulp任务进行安装。 – user2530403