Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Unit Testing Behavior Driven Development with Mocha & Chai Test Suites and Test Specs (describe and it)

SyntaxError: Unexpected token import

I encountered the following error while trying to run tests. I am using node v8.16.2, mocha v8.0.1, and chai v4.2.0.

treehouse:~/workspace$ npm test                                                                                                                               

> workspace@1.0.0 test /home/treehouse/workspace                                                                                                              
> mocha                                                                                                                                                       

/home/treehouse/workspace/node_modules/mocha/lib/esm-utils.js:6                                                                                               
    return import(url.pathToFileURL(file));                                                                                                                   
           ^^^^^^                                                                                                                                             

SyntaxError: Unexpected token import                                                                                                                          
    at createScript (vm.js:80:10)                                                                                                                             
    at Object.runInThisContext (vm.js:139:10)                                                                                                                 
    at Module._compile (module.js:617:28)                                                                                                                     
    at Object.Module._extensions..js (module.js:664:10)                                                                                                       
    at Module.load (module.js:566:32)                                                                                                                         
    at tryModuleLoad (module.js:506:12)                                                                                                                       
    at Function.Module._load (module.js:498:3)                                                                                                                
    at Module.require (module.js:597:17)                                                                                                                      
    at require (internal/module.js:11:18)                                                                                                                     
    at Object.<anonymous> (/home/treehouse/workspace/node_modules/mocha/lib/cli/run-helpers.js:18:27)

Getting the same error.