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.

Typescript example runs with errors

See original GitHub issue

Version

v2.4.5

Reproduction link

https://github.com/nuxt/nuxt.js/tree/dev/examples/typescript

Steps to reproduce

Run the app (npm run dev)

What is expected ?

“Hello from client !” should be posted in the dev console, and the app should run without issues. (I had to change the file to .js because server is not defined on the process object.

What is actually happening?

One error and 2 warnings are displayed in the console (although the site displays correctly).

ReferenceError: [nuxt] Error while mounting app: exports is not defined at Module../node_modules/babel-loader/lib/index.js?!./node_modules/ts-loader/index.js?!./node_modules/vue-loader/lib/index.js?!./pages/index.vue?vue&type=script&lang=ts& (index.js:220)

vendors.app.js:2630 ./components/HelloWorld.vue?vue&type=script&lang=ts& 1:235-238"export 'default' (imported as 'mod') was not found in '-!../node_modules/babel-loader/lib/index.js??ref--3-0!../node_modules/ts-loader/index.js??ref--3-1!../node_modules/vue-loader/lib/index.js??vue-loader-options!./HelloWorld.vue?vue&type=script&lang=ts&'./pages/index.vue?vue&type=script&lang=ts& 1:230-233"export 'default' (imported as 'mod') was not found in '-!../node_modules/babel-loader/lib/index.js??ref--3-0!../node_modules/ts-loader/index.js??ref--3-1!../node_modules/vue-loader/lib/index.js??vue-loader-options!./index.vue?vue&type=script&lang=ts&'```

<!--cmty--><!--cmty_prevent_hook-->
<div align="right"><sub><em>This bug report is available on <a href="https://cmty.app/nuxt">Nuxt</a> community (<a href="https://cmty.app/nuxt/nuxt.js/issues/c8873">#c8873</a>)</em></sub></div>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinmarreccommented, Apr 1, 2019

@MrJmpl3 will be fixed in 2.6, Nuxt won’t override your tsconfig.json anymore.

0reactions
MrJmpl3commented, Apr 1, 2019

Version: 2.5.1 , Nuxtjs add "strict": true in my custom tsconfig.json in npm run dev

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "es2015",
      "es2016",
      "es2017"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "noImplicitAny": false,
    "noImplicitThis": false,
    "noUnusedLocals": true,
    "strictNullChecks": false,
    "removeComments": true,
    "suppressImplicitAnyIndexErrors": true,
    "allowSyntheticDefaultImports": true,
    "baseUrl": ".",
    "allowJs": true,
    "jsx": "preserve",
    "paths": {
      "~/*": [
        "./*"
      ],
      "@/*": [
        "./*"
      ]
    },
    "esModuleInterop": true,
    "sourceMap": true,
    "noEmit": true,
    "types": [
      "@types/node",
      "@nuxt/vue-app"
    ]
  },
  "exclude": [
    "**/*.spec.ts",
    "node_modules"
  ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >
Detecting Errors Before Running Code With TypeScript
In examples of this post series, I will use mostly code that written in Node environment. It won't be any specific code that...
Read more >
the Example code of TS can't run but return an Error
"Typescript: Cannot use import statement outside a module",this is not solve my question.but I can use codepen or codesandbox to test react code ......
Read more >
Understanding TypeScript Errors for Beginners
Another common mistake amongst TypeScript beginners is to assume that because there are no compile-time errors there will be no run-time errors.
Read more >
Detect JavaScript errors during compile time using TypeScript ...
During compile-time TypeScript can emit errors to a terminal, ... For example, if we try to run this simple code in Node.js
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