Sample usage explanation #306
Unanswered
lawloretienne
asked this question in
Q&A
Replies: 1 comment
-
You can only use import statement inside modules. So in your case, instead of writing, Alternatively, you can change the extension from ".js" to ".mjs" to mark the source code as an ES Module (which in this case you should be able to use the import statement without any issues, but you can no longer use the require as import already does it for you). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So based on my limited knowledge with full stack development, is this library intended to be used within the Node backend code within your project? What scope within a Javascript file should an import statement be declared like this :
import { TwitterApi } from 'twitter-api-v2';
If I declare that at the top level in a Javascript file in my Node backend code i get the following error
SyntaxError: Cannot use import statement outside a module
.Is there any sample code within the project that shows where to position the code snippets into your code?
Beta Was this translation helpful? Give feedback.
All reactions