所以这可能是一个非常基本的问题,但它已经困扰我好几天了,实际上还没有找到解决方案.
我正在使用npm从命令行安装打字输出,它似乎运行良好但我输入任何打字命令,它说该命令不存在!
它类似于:
Kevyns-MacBook-Pro:~ kevynquiros$ sudo npm install typings --global
Password:
/Users/kevynquiros/npm/bin/typings -> /Users/kevynquiros/npm/lib/node_modules/typings/dist/bin.js
typings@1.0.4 /Users/kevynquiros/npm/lib/node_modules/typings
??? listify@1.0.0
??? xtend@4.0.1
??? wordwrap@1.0.0
??? archy@1.0.0
??? minimist@1.2.0
??? any-promise@1.3.0
??? bluebird@3.4.0
??? chalk@1.1.3 (supports-color@2.0.0, escape-string-regexp@1.0.5, ansi-styles@2.2.1, has-ansi@2.0.0, strip-ansi@3.0.1)
??? columnify@1.5.4 (strip-ansi@3.0.1, wcwidth@1.0.1)
??? update-notifier@0.7.0 (is-npm@1.0.0, xdg-basedir@2.0.0, semver-diff@2.1.0, ansi-align@1.0.0, boxen@0.5.1, configstore@2.0.0, latest-version@2.0.0)
??? typings-core@1.0.1 (array-uniq@1.0.2, thenify@3.2.0, zip-object@0.1.0, popsicle-status@2.0.0, graceful-fs@4.1.4, popsicle-retry@3.1.0, throat@2.0.2, lockfile@1.0.1, promise-finally@2.2.0, string-template@1.0.0, strip-bom@2.0.0, sort-keys@1.1.2, make-error-cause@1.1.0, debug@2.2.0, has@1.0.1, rc@1.1.6, object.pick@1.1.2, configstore@2.0.0, parse-json@2.2.0, invariant@2.2.1, detect-indent@4.0.0, mkdirp@0.5.1, touch@1.0.0, is-absolute@0.2.5, popsicle-proxy-agent@2.0.1, rimraf@2.5.2, typescript@1.8.7, popsicle@6.2.0) …Run Code Online (Sandbox Code Playgroud) 因此,我在一个需要调用服务器并返回zip文件的网站上工作,事实是我不确定自己是否做对了所有事情。代码看起来像这样:
function download(){
if($('.download').hasClass('activeBtn')){
$.ajax({
type: 'GET',
url: someUrl,
contentType: 'application/zip',
dataType: 'text',
headers: {
'Api-Version': '3.4'
}
}).then(function (data) {
console.log(data); //Basically prints the byte array
//Here I should build the file and download it
});
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我需要使用响应中的字节数组来填充文件,我该怎么做?