When this line is executed:
import stats from `./${process.env.STATS}`
the error below is reported:
Parsing error: Unexpected token `
The module can be loaded successfully with the expression:
const stats = require(`./${process.env.STATS}`);
The import
statement seems to require a regular string as it works with the statement:
import stats from './statsdir'
where './statsdir'
is the value of process.env.STATS
.
Why does the error occur?