Make an NFT tutorial issue - Ethers not defined

I have followed the setup twice all the way through and still get this error.
Link to Tutorial:How to Make an NFT in 14 Lines of Code
Im on MacOs Mojave
Error:
ReferenceError: ethers is not defined
at main (/Users/name/nft-project/ethereum/scripts/deploy.js:2:27)
at Object. (/Users/name/nft-project/ethereum/scripts/deploy.js:8:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions…js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47

I’m not sure without seeing your code, but, it looks like it may be an import issue with the ethers.js library

So maybe I could try waffle instead to see?

I probably would just review the steps up to where you are so far, and make sure nothing was missed.

did you do this

npm install @nomiclabs/hardhat-ethers --save-dev

and then modify your hardhat config with the below line

require("@nomiclabs/hardhat-ethers");

Yup yup. I’m not a programmer but been a network engineer over 20 years so def have attention to details. I’ll try again but it all looks good

I understand, but ‘stuff’ happens.

Yup thx again! I may try to compile with waffle just for fun since I’ve never used it
I should get the same error basically if it’s my config files
Guess I could try on my windows Box

It could be fun. I’ve only messed around with truffle. I think I’m gonna try this out later today.

I ran into the same problem on win10.

After a bit of tinkering I figured out how. . . to get it to deploy.

In the deploy script, on the line before you getContractFactory add:
const { ethers } = require('hardhat');

then it should work.

I got it to deploy after adding that line.
After that it should be smooth sailing.

Hopefully that helps you.

awesome! I googled and found that too but didn’t place it in the correct place in the script
Thanks!!!

1 Like

No problem. It was whooping me when I got to that issue.