2015-07-13 80 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.