skip to Main Content

Was following this article ran the command

npm install --dev hardhat @nomicfoundation/hardhat-toolbox

got the successful response. However when I try to run the

npx hardhat

getting Unexpected token ? response.

Tried removing the package-local.json. Also tried removing the global installation. Nothing worked.

3

Answers


  1. I also got the same error!

      ~ npx hardhat Unexpected token '?'
    

    After i upgrade my nodejs version to v16.17.0 and npm version to 8.15.0, error is gone

    Once the reported error is gone then you should see the below message

    ➜  ~ npx hardhat
    888    888                      888 888               888
    888    888                      888 888               888
    888    888                      888 888               888
    8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888
    888    888     "88b 888P"  d88" 888 888 "88b     "88b 888
    888    888 .d888888 888    888  888 888  888 .d888888 888
    888    888 888  888 888    Y88b 888 888  888 888  888 Y88b.
    888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888
    
    👷 Welcome to Hardhat v2.11.2 👷‍
    
    Login or Signup to reply.
  2. I have had a similar issue attempting to install hardhat via
    npx hardhat.

    I found the solution from user I Like resolved this. Make sure you are using correct version of node. try nvm use 18

    nvm install 18 
    npx hardhat 
    

    and had success!

    Login or Signup to reply.
  3. I also got the same error when I was installing the hardhat:

    let taskName = parsedTaskName ?? task_names_1.TASK_HELP;
    
    SyntaxError: Unexpected token '?'
    

    try this command on your terminal

    nvm use 18
    nvm install 18
    

    basically above commands will increase your node.js and npm version

    then try to install

    npx hardhat
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search