'Keep hitting an error when trying to use export/import in JavaScript using Atom
I'm trying to write an array in one .js that can be exported to another, but when I try to import it into the other.js Atom keeps throwing me back the following error:
/Users.../GitHub/my-first-advent-of-code-javascript-2020/github/day-01/input-data.js:1
export const myNumberInput = [1757,
^^^^^^SyntaxError: Unexpected token 'export' at wrapSafe (node:internal/modules/cjs/loader:1018:16) at Module._compile (node:internal/modules/cjs/loader:1066:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10) at Module.load (node:internal/modules/cjs/loader:967:32) at Function.Module._load (node:internal/modules/cjs/loader:807:14) at Module.require (node:internal/modules/cjs/loader:991:19) at require (node:internal/modules/cjs/helpers:92:18) at [stdin]:3:18 at Script.runInThisContext (node:vm:133:18) at Object.runInThisContext (node:vm:310:38) [Finished in 0.451s]
The code to be exported is a basic number based array (it's longer than this but this is the format:
export const myNumberInput = [1757, 1890, 1750, 1440, 1822, 1957];
the import code is import {myNumberInput} from '/Users/.../GitHub/my-first-advent-of-code-javascript-2020/github/day-01/input-data.js';
I've looked online, but I don't understand why I'm getting this error, I've triple checked my syntax. Is this an Atom thing or an ES6 thing or a Node.JS problem (I hope not the latter, I really don't understand that yet)? I'm still learning and not great at problem solving yet. Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|