Function to work when I put import, Function does not work, import does not work

Asked

Viewed 62 times

0

I got into a problem here that I can’t solve the problem and the next:

I ran -> npm install fontfaceobserver

then went there in the code -- code.js

ai pus import --> import Fontfaceobserver from 'fontfaceobserver';

but when I do that, all functions stop working, they change color,

I did the basic functions

function teste1(){alert('teste')}

let’s assume, this function works without import, when I put the import it and all the others stop working, I will put the photo below.

Version of nodes and npm C:>Node --version v14.17.5 C:>npm --version 6.14.14

to run the project simply give a F5 in index, then it already updates with all the changes I do, do not need to build in the project

am using Visual Studio Code

Just remember, I’m a latte in this programming business so I may be making a basic mistake.

I’m trying to use this github code https://github.com/bramstein/fontfaceobserver

inserir a descrição da imagem aqui

  • It is not clear if you are using a library that builds some form of the project, but the version of the nodejs you are using, depending on the version does not have native support for the command import.

  • 1

    done, made the changes

  • That’s what @Danizavtz said above... check the version you’re using and the minimum version with Imports support. You need to use something to "buildar", turn into code that is accepted by current browsers. The Babel, for example.

  • I am watching the videos of Babel I will implement here, I recorded a video of the problem https://youtu.be/DyklaJoNe04

  • 1

    At last it worked, I’m new and started alone so I was doing everything without a framework, then I installed React and import worked like the image above, I still didn’t need Babel, but I’ll install Babel later. thank you all

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.