Rolluperror: unexpected token (note that you need plugins to import files that are not javascript)

Explanation:

An unexpected token error occurs when there is a syntax error in your JavaScript code. The error message you provided suggests that there is a problem with a specific file import, mentioning that you need plugins to import files that are not JavaScript.

Here’s an example to illustrate this:


import { add } from './utils/math.js';
// Error: Unexpected token '{'

function sum(a, b) {
  return add(a, b);
}
  

In this example, the unexpected token error occurs when trying to import the ‘add’ function from the ‘./utils/math.js’ file. This error usually happens because the JavaScript module syntax is not supported in the current environment, or it requires a plugin or transformation to be used.

To resolve this issue, you will need to make sure that your project is set up with the necessary plugins or tools to handle non-JavaScript file imports. For example, if you are using a bundler like Webpack, you may need to add additional loaders or plugins to handle imports of files that are not JavaScript (e.g., CSS, images, JSON, etc.).

Similar post

Leave a comment