question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

es6 import syntax error

See original GitHub issue

Hi!

I try to use inject-loader on a following file:

import AuthResource from './../../resources/auth/Auth';
import { REMOVE_TOKEN, SET_TOKEN } from '../actions';

export default {
// ...
};

with code

const actionsInjector = require('inject!./actions');

and an error appears

ERROR in ./~/inject-loader/dist!./resources/assets/js/store/auth/auth.js
Module parse failed: /home/megapixel23/Projects/vue-demo/node_modules/inject-loader/dist/index.js!/home/megapixel23/Projects/vue-demo/resources/assets/js/store/auth/auth.js 'import' and 'export' may only appear at the top level (26:6)
You may need an appropriate loader to handle this file type.
|     (function () {
|       // $FlowIgnore
|       import AuthResource from './../../resources/auth/Auth';
| import { REMOVE_TOKEN, SET_TOKEN } from '../actions';
| 
 @ ./resources/assets/js/store/auth/auth.spec.js 2:24-58

Seems like es6 import syntax does not work in inject-loader

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
hershmirecommented, Sep 27, 2018

@plasticine Do you have any examples with Babel 7? I’m getting similar issues once upgrading to Babel 7. Worked fine with Babel 6.

1reaction
plasticinecommented, Jan 15, 2017

@MEGApixel23 Please check out the examples in the repo — specifically the webpack config. This is not an issue with inject-loader, you’re just missing some config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js - SyntaxError: Unexpected token import - Stack Overflow
Enable ES6 imports in node js provides a solution to this issue. I have tried this and it worked for me. Run the...
Read more >
Why your ES6+ syntax doesn't work in Node.js and how to fix it
json file by running of the following two commands in your project directory. npm init // npm int. Packages. Node modules can be...
Read more >
Unexpected token import Node.js - Reactgo
When we use es6 modules import/export statements in Node.js. It gives a following error in the terminal because node is currently not supporting...
Read more >
JavaScript : ES6 module Import giving "Uncaught SyntaxError
JavaScript : ES6 module Import giving "Uncaught SyntaxError : Unexpected identifier" [ Gift : Animated Search Engine ...
Read more >
can not use import statement outside a module - YouTube
JS - JavaScript. syntaxerror - can not use import statement outside a module | es6 vs commonjs modules in nodejs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found