您可能需要一个合适的加载器来处理这种文件类型。打字稿
问题描述:
我想利用打字稿分型,为您的Youtube API的数据在这里:https://github.com/Bolisov/typings-gapi/tree/master/gapi.client.youtube-v3您可能需要一个合适的加载器来处理这种文件类型。打字稿
我使用离子框架,我收到以下后我不离子在下面的一行代码即成错误:
gapi.client.load("client", "v3");
Module parse failed: /Users/yoko/Desktop/myApp/node_modules/gapi/lib/gapi.coffee Unexpected token (1:17)
You may need an appropriate loader to handle this file type.
| config = require './config'
|
| module.exports =
这是api.coffee怎么看起来像
config = require './config'
module.exports =
server:
setApiKey: (apiKey) ->
config.api.key = apiKey
load: (apiName, apiVersion, callback) ->
@[apiName] = require "./#{apiName}/#{apiVersion}"
callback()
这是什么意思?
答
假设你使用的是咕嘟咕嘟,通过NPM安装CoffeeScript的,那么它通过添加到您的package.json
:
npm install gulp-coffee --save-dev #devDependencies
或
npm install gulp-coffee --save #dependencies
然后添加以下到您的Gulpfile.js:
var coffee = require('gulp-coffee');
var paths = { coffee: ['/Users/yoko/Desktop/myApp/node_modules/gapi/lib/*.coffee'] };
function coffeePipe(done)
{
gulp.src(paths.coffee)
.pipe(coffee({bare: true})
.on('error', gutil.log.bind(gutil, 'Coffee Error')))
.pipe(concat('application.js'))
.pipe(gulp.dest('./www/js'))
.on('end', done)
}
gulp.task('coffee', coffeePipe);
参考文献
意味着你需要设置cofeescript transpilation。 –
如何在角度项目中设置此项? –
需要使用加载程序,SystemJS或Webpack,或者您可以运行一个将文件编译为JS的监视任务,并包含这些文件 –