Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modul-Unterstützung #2

Closed
Markus1397 opened this issue May 5, 2020 · 6 comments · Fixed by #6
Closed

Modul-Unterstützung #2

Markus1397 opened this issue May 5, 2020 · 6 comments · Fixed by #6

Comments

@Markus1397
Copy link

Zunächst einmal danke für deine tollen Tutorials!

Bin beim Versuch deinem Video zum Thema Echzeit-Statistiken zu folgen leider auf ein kleines Problem gestoßen.
Leider schaffe ich es nicht die benötigenten Module (siehe ca. 22:30) einzubinden.
Hat sich seit her das Handling von Modulen verändert oder ist das momentane Setup der dev-env nicht auf die Verwendung von modules ausgelegt.

@Johannes-Schiel
Copy link
Owner

Was für Module willst du den Importieren? bzw. was hast du bissher gemacht um die zu Imprtieren?

@Markus1397
Copy link
Author

Konkret würde es um 'socket.io-client' und 'chart.js' gehen.
Die Packete sind via NPM installiert worden (mit der der Option --save).
Im JavaScript habe ich versucht die beiden Module mittels folgender Zeilen einzubinden:
import Chart from 'chart.js'; import io from 'socket.io-client';
browserify wirft beim ausführen des Gulp-Tasks folgende Fehlermeldung:

import Chart from 'chart.js';
^
ParseError: 'import' and 'export' may only appear at the top level

@daferner
Copy link

Ja, das gleiche Problem habe ich auch... hab es mit Jquery und AnimeJS versucht

import $ from "jqeruy"; und import animejs from "animejs";

jeweils der Fehler:

src/js/main.js
line 1 col 1 'import' is only available in ES6 (use 'esversion: 6').

⚠ 1 warning
/Users/xxxx/web/xxxx/src/js/fake_505eb3f6.js:2
import animejs from "animejs";
^
ParseError: 'import' and 'export' may only appear at the top level

@micschwarz
Copy link
Contributor

@daferner @Markus1397 Das Problem lässt sich relativ leicht beheben:
Erstellt eine .jshintrc-Datei im root mit folgendem Inhalt:

{
    "esversion": 6
}

Die Zahl kann auch entsprechend höher gesetzt werden (Bis 10) um weitere Features zu erlauben.
Siehe https://jshint.com/docs/options/#esversion

@daferner
Copy link

Hallo @micschwarz,
vielen Dank für deine Hilfe... leider hat das meine Fehlermeldung nur verändert und ich bekomme jetzt folgende Meldung:

/Users/xxx/web/xxx/src/js/fake_b39027f9.js:2
import animejs from "animejs";
^
ParseError: 'import' and 'export' may only appear at the top level

@micschwarz
Copy link
Contributor

@daferner funktioniert dein Code denn? Das ist nur eine Warnung von Jshint, die sollte nichts ausmachen. Die kannst du ignorieren bis das behoben ist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants