简体   繁体   中英

Getting a ReferenceError: Can't find variable: require

** I have install (npm install statistics.js) but I am still getting an error saying can't find require. **

const Statistics = require("node_modules/statistics.js/statistics.js");

var bodyMeasurements = [
  { weight: 63, height: 1.65 },
  { weight: 64, height: 1.67 },
  { weight: 74, height: 1.8 },
  { weight: 79, height: 1.82 },
  { weight: 82, height: 1.86 },
  { weight: 66, height: 1.7 },
  { weight: 91, height: 1.83 },
  { weight: 72, height: 1.76 },
  { weight: 85, height: 1.89 },
  { weight: 68, height: 1.68 },
];

var bodyVars = {
  weight: "metric",
  height: "metric",
};

var stats = new Statistics(bodyMeasurements, bodyVars);
var r = stats.correlationCoefficient("weight", "height");

function myFunc() {
  console.log(r);
}

** I have install (npm install statistics.js) but I am still getting an error saying can't find require. **

const Statistics = require("node_modules/statistics.js/statistics.js");

var bodyMeasurements = [
  { weight: 63, height: 1.65 },
  { weight: 64, height: 1.67 },
  { weight: 74, height: 1.8 },
  { weight: 79, height: 1.82 },
  { weight: 82, height: 1.86 },
  { weight: 66, height: 1.7 },
  { weight: 91, height: 1.83 },
  { weight: 72, height: 1.76 },
  { weight: 85, height: 1.89 },
  { weight: 68, height: 1.68 },
];

var bodyVars = {
  weight: "metric",
  height: "metric",
};

var stats = new Statistics(bodyMeasurements, bodyVars);
var r = stats.correlationCoefficient("weight", "height");

function myFunc() {
  console.log(r);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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