2015-07-13 77 views
4

普通的JavaScript我只是想有一个准备使用编译普通的JavaScript文件,从这个仓库https://github.com/airbrake/airbrake-js如何从故宫

如何制作的?这简直让我疯狂,我不wan't任何凉亭,NPM或什么 - 只有一个普通的JavaScript文件

BTW:文件“https://raw.githubusercontent.com/airbrake/airbrake-js/master/dist/client.js”是我想要什么有辩论,因为有依然是“要求(‘./内部/ COMPAT’);”内;-)

问候

回答

1

使用树系统中可用的GitHub的页面上导航到你想要的文件,然后点击查看按钮,然后原始获取该文件的源代码,没有所有的行号。

+0

伙计,我不wan't知道如何通过在github上一个文件浏览 - 我需要知道如何编译这个js文件:https://raw.githubusercontent.com/airbrake/airbrake-js/master/dist/client.js到一个简单的js文件;没有任何“require('./ internal/compat');”或任何其他insect ;-) –

1

获取/下载/拷贝这两个文件,并将其包含在HTML:

https://raw.githubusercontent.com/airbrake/airbrake-js/master/dist/client.js https://raw.githubusercontent.com/airbrake/airbrake-js/master/dist/instrumentation/jquery.js

<script src="js/airbrake-js/client.js"></script> 
<script src="js/airbrake-js/instrumentation/jquery.js"></script> 

还请legacy example检查:

添加文件后添加这个剧本太:

var airbrake = new airbrakeJs.Client({projectId: 1, projectKey: 'abc'}); 
if (window.jQuery) { 
    airbrakeJs.instrumentation.jquery(airbrake, jQuery); 
} 

try { 
    throw new Error('hello from airbrake-js'); 
} catch (err) { 
    airbrake.push(err); 
} 
+0

但在这个文件是stil **“require('./ internal/compat');”**和其他require语句里面。我需要填写需求文件的文件。 –

+0

已更新的答案,我想建议您阅读Github自述文件并查看示例。 –

+0

请看看第5行https://raw.githubusercontent.com/airbrake/airbrake-js/master/dist/client.js ...如何解决这个该死的“require('./ internal/compat' );” ?????????????我可以阅读自述文件!关于“要求('./ internal/compat')的内容”;“ ???????????? –

0

如果您打算从浏览器中使用此代码,预计您将使用browserify:http://browserify.org/

Browsers don't have the require method defined, but Node.js does. With Browserify you can write code that uses require in the same way that you would use it in Node.