[Vuejs]-"Cannot use import statement outside a module" got message when I try to mocha

3👍

You cannot use the import syntax in a Node app (import { expect } from 'chai';) if your project isn’t properly configured to use this newer syntax. The original Node syntax pre JS modules is const variable = require('./folder/file')

You have to set up Jest or the project you work on to work with ES6 Modules. In package.json, add "type": "module". Here’s an explanation: https://www.geeksforgeeks.org/how-to-use-an-es6-import-in-node-js/

Leave a comment