Reputation: 13385
For some reason I'm unable to use an array exported as an es6 module:
export const choices = [
['first', 'First'],
['second', 'Second'],
['third', 'Third'],
]
Then:
import { choices } from './constants'
console.log(choices) // undefined
If I simply declare the const
in the same file where I'm trying to use it, it works as expected.
Upvotes: 11
Views: 13178
Reputation: 1074295
Modules in browser contexts use relative URLs, including extension. So the import should be from './constants.js'
rather than just from './constants'
. (The latter would be fine on Node.js, though, with its currently-experimental modules support.)
Upvotes: 8