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.

using @nuxt/typescript-build causes dead loop (npm only)

See original GitHub issue

Describe the bug When I run nuxt app using nuxt-ts in hoisted lerna monorepo, it causes weird behavior: when I open serve address, see 5 continuous reloads and this message: image

To Reproduce Steps to reproduce the behavior:

  1. Clone repository https://github.com/georgyfarniev/nuxt_lerna_repro
  2. Run npm i && npm run bootstrap
  3. Run cd repro && npm run dev
  4. Open localhost:7005
  5. See error described above

Expected behavior Working correctly with hoisted lerna monorepo.

Additional context Reproducible in both Windows 10 and Node 12, as well as Arch Linux with Node 12. Please pay attention to lerna.json, as hoisted mode are enabled there.

Also, it’s probably nuxt-ts issue, because everything works well with plain nuxt

This bug is a critical blocker for us, since we cannot use our applications written in nuxt+typescript using our lerna setup which is vital for us, so I will keep monitoring this issue and I’m ready to provide any possible assistance with fixing it.

Issue Analytics

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

github_iconTop GitHub Comments

11reactions
ebelodedcommented, Oct 17, 2020

@frankier @lights0123

I had the same issue (ERROR When you use this plugin you must install typescript). Was able to resolve it in nuxt.config:

[
      '@nuxt/typescript-build',
      {
        typeCheck: {
          typescript: require.resolve('typescript'),
        },
      },
    ],
]
6reactions
lights0123commented, Oct 2, 2020

I get this error:

 ERROR  When you use this plugin you must install typescript.                                                        19:01:42

  at ForkTsCheckerWebpackPlugin.validateTypeScript (/project/node_modules/fork-ts-checker-webpack-plugin/src/index.ts:250:13)
  at new ForkTsCheckerWebpackPlugin (/workspace/node_modules/fork-ts-checker-webpack-plugin/src/index.ts:197:14)
  at WebpackBundler.<anonymous> (/workspace/node_modules/@nuxt/typescript-build/src/index.ts:77:28)
  at WebpackBundler.<anonymous> (/workspace/node_modules/@nuxt/utils/dist/utils.js:1875:29)
  at WebpackClientConfig.extendConfig (/workspace/node_modules/@nuxt/webpack/dist/webpack.js:4884:37)
  at WebpackClientConfig.config (/workspace/node_modules/@nuxt/webpack/dist/webpack.js:4919:45)
  at WebpackClientConfig.config (/workspace/node_modules/@nuxt/webpack/dist/webpack.js:5083:26)
  at WebpackBundler.getWebpackConfig (/workspace/node_modules/@nuxt/webpack/dist/webpack.js:5391:19)
  at WebpackBundler.build (/workspace/node_modules/@nuxt/webpack/dist/webpack.js:5398:12)
  at Builder.build (/workspace/node_modules/@nuxt/builder/dist/builder.js:5643:30)
  at Object._buildDev (/workspace/node_modules/@nuxt/cli/dist/cli-dev.js:106:5)
  at Object.startDev (/workspace/node_modules/@nuxt/cli/dist/cli-dev.js:64:7)
  at Object.run (/workspace/node_modules/@nuxt/cli/dist/cli-dev.js:51:5)
  at NuxtCommand.run (/workspace/node_modules/@nuxt/cli/dist/cli-index.js:2809:7)

I’m using a yarn workspace. The error occurs in the catch statement:

const typescriptPath = options.typescript || require.resolve('typescript');
const tsconfig = options.tsconfig || './tsconfig.json';
const compilerOptions = typeof options.compilerOptions === 'object'
    ? options.compilerOptions
    : {};
let typescript, typescriptVersion;
try {
    typescript = require(typescriptPath);
    typescriptVersion = typescript.version;
}
catch (_ignored) {
    throw new Error('When you use this plugin you must install `typescript`.');
}

The variable typescriptPath is equal to:

{
  configFile: '/workspace/project/tsconfig.json',
  extensions: {
    vue: true
  }
}

The following change makes the build succeed:

- const typescriptPath = options.typescript || require.resolve('typescript');
+ const typescriptPath = require.resolve('typescript');

so this module seems to be passing an object when a string is expected. However, that seems to be because the version of fork-ts-checker-webpack-plugin that yarn decided to install was version 3, even though this project asks for v5 (it installs a separate package, fork-ts-checker-webpack-plugin-v5, that does not exist on npm). This is because I had a vue-cli app in another package, which uses v3. Adding fork-ts-checker-webpack-plugin as a dev dependency to my package fixed the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nuxt/typescript-build
Start using @nuxt/typescript-build in your project by running ... There are 22 other projects in the npm registry using @nuxt/typescript-build.
Read more >
what are the common causes for an infinite loop in vue js
For me it's passing in a prop and mutating it and emitting an event which triggers the prop to mutate upstream. That's pretty...
Read more >
A Clean and Simple Approach for Unit Testing ...
A dead-simple production code example of testing a TypeScript/JavaScript business rule with ts-jest. It's not the purpose of that article so ...
Read more >
Updating to Nuxt Bridge
FATAL Please remove @nuxt/typescript-build from buildModules or set ... error just happens at random, causing the infinite loop problem.
Read more >
Nuxt "npm run dev" build loop after setting up Tailwind CSS ...
The problem is the following line: module.exports = { content: [ './nuxt.config.{js,ts}', ] }. Change to (or simply keep only the one you ......
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