Skip to content

Color Contrast Example - Build Error #524

@retiutut

Description

@retiutut

A GIF or MEME to give some spice of the internet

What is wrong?

npm run build fails with slightly modified color contrast example

Where does it happen?

It happens when trying to run npm run build on my Mac running NodeJS LTS.

How do we replicate the issue?

Build script in package.json: "build": "cross-env BABEL_ENV=production babel src --out-dir lib",

src/index.js -> lib/index.js
TypeError: src/neuralNetTest.js: Cannot read property 'contexts' of null

As you can see, I have an index.js that is able to build, but the example code contained in src/neuralNetTest.js shows a TypeError.

How important is this (1-5)?

4-5

Expected behavior (i.e. solution)

Build without errors

Other Comments

const brain = require('brain.js');

const net = new brain.NeuralNetwork();

const trainNN = () => {
  net.train([{
    input: {
      r: 0.03,
      g: 0.7,
      b: 0.5
    },
    output: {
      black: 1
    }
  },
  {
    input: {
      r: 0.16,
      g: 0.09,
      b: 0.2
    },
    output: {
      white: 1
    }
  },
  {
    input: {
      r: 0.5,
      g: 0.5,
      b: 1.0
    },
    output: {
      white: 1
    }
  }
  ]);
};

const runNN = (red, green, blue) => {
  trainNN();

  const output = net.run({
    r: red,
    g: green,
    b: blue
  }); // { white: 0.99, black: 0.002 }

  return output;
};

export { trainNN, runNN };

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions