i'm getting uncaught type error of: Uncaught TypeError: Cannot set property 'onclick' of null
<!DOCTYPE html>
<html>
<head>
<title>dice app</title>
<script src="widget.js"></script>
</head>
<body>
<button id="button">Roll Dice</button>
</body>
</html>
js code:
var button = document.getElementById("button");
button.onclick = function() {// error
var print = dice.roll();
printNumber(print);
};