Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/tutorials.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ const moment = require('moment');
const axiosPath = require('./axiosPath');

const tutorials = [
{
title: "How to Fix \"cannot use import statement outside a module\" in JavaScript",
raw: './tutorials/fundamentals/import-outside-module-error.md',
url: '/tutorials/fundamentals/import-outside-module-error',
description: 'Placeholder Description',
tags: ['fundamentals'],
date: moment('2022-12-02')
},
{
title: 'Use the Ternary Operator for Conditionals in Vue',
raw: './tutorials/vue/ternary-operator.md',
Expand Down
28 changes: 28 additions & 0 deletions tutorials/fundamentals/import-outside-module-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
In Node, you can use `"type": "module"` in package.json

```json
{
"type:": "module"
}
```

## In the browser

In the script tag, you add `type="module"` like so:

```html
<script type="module" src="./file.js">import
</script>
```
<script type="module" src="./file.js">import
</script>

```html
<script src="./file.js">import
</script>
```
<script>
import
</script>

Observe how the error is thrown without that change by pressing ctrl+shift+i if you are on windows.