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.

Nested import error: TypeError: "header.$$ is undefined".

See original GitHub issue

🐛 Bug Report

Nested import error: TypeError: "header.$$ is undefined". Without import app works normally, with import I get this error.

🎛 Configuration

{
  "name": "sveltetest",
  "version": "1.0.0",
  "description": "",
  "main": "index.html",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "browserslist": [
    "last 1 chrome versions",
    "last 1 firefox version"
  ],
  "author": "Janealter",
  "license": "ISC",
  "devDependencies": {
    "@babel/polyfill": "^7.4.4",
    "parcel-bundler": "^1.12.3",
    "parcel-plugin-svelte": "^3.0.1",
    "svelte": "^3.4.4"
  }
}

Commands: ./node_modules/parcel-bundler/bin/cli.js index.html --no-cache; ./node_modules/parcel-bundler/bin/cli.js index.html; parcel index.html; parcel index.html --no-cache

💻 Code Sample

./index.html

<!DOCTYPE html> 
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Svelte Test</title>
  </head>
  <body>
    <main></main>
    <script src="src/index.js"></script>
  </body>
</html>

./src/index.js

import '@babel/polyfill';
import App from './App';

const app = new App({
  target: document.querySelector('main'),
  data: {},
});

./src/App.svelte

<script>
  import Header from './components/Header';

  const name = 'Test';
</script>

<p>{name}</p>
<Header/>

./src/components/Header.svelte

<header>
  <p>Test text</p>
</header>

🌍 Your Environment

Svelte 3.4.4, Parcel 1.12.3

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
orlov-vocommented, Jul 9, 2019

yes, it’s problem related with HMR. you can use simple workaround with disabling hot reloading: parcel --no-hmr index.html

2reactions
hectorlfcommented, Jul 6, 2019

Just in case this helps, as it is not explicitly mentioned. I’m seeing:

TypeError: Cannot read property ‘fragment’ of undefined at Object.c (Hello.svelte:117)

With the most simplest nested component. The thing is that this only happens when running “parcel” or “parcel watch”, running “parcel build” generates a correct output.

parcel: 1.12.3 parcel-plugin-svelte: 3.0.1 svelte: 3.6.4

Read more comments on GitHub >

github_iconTop Results From Across the Web

React When i am trying to get into a nested object the fetch ...
when i try to get into the pokemon.types.type.name i get a error saying Uncaught TypeError: Cannot read properties of undefined (reading ...
Read more >
Features | Vite
Vite caches dependency requests via HTTP headers, so if you wish to locally ... Use the Type-Only Imports and Export syntax to avoid...
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >
Python import: Advanced Techniques and Tips
The Python import system is as powerful as it is useful. In this in-depth tutorial, you'll learn how to harness this power to...
Read more >
Troubleshooting | React Navigation
If the module points to an npm package (i.e. the name of the module doesn't with ./ ), then it's probably due to...
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