简体   繁体   English

'require'未定义VS代码

[英]'require' is not defined VS Code

I am brand new to VS Code.我是 VS Code 的新手。 As the title suggests I am trying to require various SDK's for my JEE to run properly.正如标题所示,我试图要求各种 SDK 让我的 JEE 正常运行。 When I try to go live the console spits out this error:当我尝试 go 直播时,控制台会吐出这个错误:

Uncaught ReferenceError: require is not defined
at fbaccess.js:10

I remember from my dev days with Android that we always had a manifest file to require things, but I am not sure how to import/properly call things globally in VS Code.我记得在 Android 的开发日中,我们总是有一个清单文件来要求东西,但我不确定如何在 VS Code 中全局导入/正确调用东西。

This is the fbaccess.js code that is supposed to call some sample data (Outputted in node.js:这是应该调用一些示例数据的 fbaccess.js 代码(在 node.js 中输出:

  /**
 * Copyright (c) 2017-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the license found in the
 * LICENSE file in the root directory of this source tree.
 * @flow
 */

const bizSdk = require('facebook-nodejs-business-sdk');
const AdAccount = bizSdk.AdAccount;
const AdsInsights = bizSdk.AdsInsights;

let access_token = '****';
let ad_account_id = '****';
let app_secret = '****';
let app_id = '****';
const api = bizSdk.FacebookAdsApi.init(access_token);
const account = new AdAccount(ad_account_id);
const showDebugingInfo = true; // Setting this to true shows more debugging info.
if (showDebugingInfo) {
  api.setDebug(true);
}

let ads_insights;
let ads_insights_id;

const logApiCallResult = (apiCallName, data) => {
  console.log(apiCallName);
  if (showDebugingInfo) {
    console.log('Data:' + JSON.stringify(data));
  }
};

const fields = [
  'results',
  'impressions',
  'spend',
  'quality_score_organic',
];
const params = {
  'level' : 'campaign',
  'filtering' : [],
  'breakdowns' : [],
  'time_range' : {'since':'2019-10-09','until':'2019-10-09'},
};
 (new AdAccount(ad_account_id)).getInsights(
  fields,
  params
).then((result) => {
  logApiCallResult('ads_insights api call complete.', result);
  ads_insights_id = result[0].id;
})
.catch((error) => {
  console.log(error);
});

Any help would be appreciated!任何帮助,将不胜感激!

Add this to the html in the head.将此添加到头部的 html 中。

 <script type="text/javascript" src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script>
 <script type="text/javascript" src="https://unpkg.com/web3@0.20.5/dist/web3.min.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM