DEV Community

Discussion on: The Complete Guide to Full Stack Ethereum and EVM Development

Collapse
 
chiranz profile image
Chiranjibi Poudyal

I am doing this project in typescript, when I run "npx hardhat node" it throws an error saying

An unexpected error occurred:

/home/chiranz/programming/blockchain/smartcontracts/tutorials/react-dapp/hardhat.config.ts:12
export default config;

SyntaxError: Unexpected token 'export'
Enter fullscreen mode Exit fullscreen mode

What am I missing here ?

import { HardhatUserConfig } from "hardhat/types";
const config: HardhatUserConfig = {
  solidity: {
    compilers: [{ version: "0.8.3", settings: {} }],
  },
  paths: { artifacts: "./src/artifacts" },
  networks: {
    hardhat: {
      chainId: 1337,
    },
  },
};

export default config;
Enter fullscreen mode Exit fullscreen mode
Collapse
 
lpatipat profile image
lpatipat

I also ran into this with typescript for hardhat. Did you ever find a solution?

Collapse
 
lpatipat profile image
lpatipat

Update:

just found a fix:

update the hardhat.config.ts file with

"module": "commonjs"

Collapse
 
mmatila profile image
Manu Matila

Also ran into this issue. create-react-app Typescript template had created a tsconfig file for me, that had "module": "esnext". Changing it to "module": "commonjs" ended up fixing the issue for me.