{"id":429,"hash":"8d4efacaaf08c750b28515e1ab1ea1c99afe76a94bdc1ed2523f760bd27a71a4","pattern":"Getting Unexpected Token Export","full_message":"I am trying to run some ES6 code in my project but I am getting an unexpected token export error.\n\nexport class MyClass {\n  constructor() {\n    console.log(\"es6\");\n  }\n}","ecosystem":"npm","package_name":"ecmascript-6","package_version":null,"solution":"Updated for 2022\n\nYou are using EcmaScript Module (ESM or 'ES6 Modules') syntax  but your environment does not support it.\n\nNodeJS versions prior to v14.13.0 do not support ESM (export keyword syntax) and use CommonJS Modules (module.exports property syntax). NodeJS v14.13.0 and newer supports ESM but it must be enabled first.\n\nSolutions:\n\nIf you are using NodeJS v14.13.0 or newer (which does support ESM) you can enable it by setting \"type\":\"module\" in your project package.json\nRefactor with CommonJS Module syntax (for older versions of NodeJS)\nConsider using TypeScript alongside ts-node or ts-node-dev npm packages (for instant transpilation at development time) and write TypeScript in .ts files\nTranspile ESM to CommonJS using esbuild (esbuild package on npm) configured to transpile your ES6 javascript to a CommonJS target supported by your environment. (babel is no longer recommended)","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/38296667/getting-unexpected-token-export","votes":580,"created_at":"2026-04-19T04:51:08.337525+00:00","updated_at":"2026-04-19T04:51:22.563766+00:00"}