Xo: [has workaround] XO not working with TypeScript: Cannot find module 'json-schema'

Created on 12 May 2020  路  2Comments  路  Source: xojs/xo

Apparently xo is simply not working with typescript. Steps to reproduce:

  • New empty folder
  • npm init -y
  • npm install --save-dev typescript xo
  • Create a new file index.ts:
    js console.log('test');
  • npx xo

    Error: Failed to load parser 'C:\Users\Pedro\Desktop\xo-not-working\node_modules\@typescript-eslint\parser\dist\parser.js' declared in 'BaseConfig': Cannot find module 'json-schema'
    Require stack:
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\@typescript-eslint\experimental-utils\dist\json-schema.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\@typescript-eslint\experimental-utils\dist\index.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\@typescript-eslint\parser\dist\analyze-scope.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\@typescript-eslint\parser\dist\parser.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\eslint\lib\cli-engine\config-array-factory.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\eslint\lib\cli-engine\cli-engine.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\eslint\lib\cli-engine\index.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\eslint\lib\api.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\xo\index.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\xo\cli-main.js
    - C:\Users\Pedro\Desktop\xo-not-working\node_modules\xo\cli.js
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
      at Function.Module._load (internal/modules/cjs/loader.js:686:27)
      at Module.require (internal/modules/cjs/loader.js:848:19)
      at require (internal/modules/cjs/helpers.js:74:18)
      at Object.<anonymous> (C:\Users\Pedro\Desktop\xo-not-working\node_modules\@typescript-eslint\experimental-utils\dist\json-schema.js:7:10)
      at Module._compile (internal/modules/cjs/loader.js:955:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
      at Module.load (internal/modules/cjs/loader.js:811:32)
      at Function.Module._load (internal/modules/cjs/loader.js:723:14)
      at Module.require (internal/modules/cjs/loader.js:848:19)
    
  • Running npm install --save-dev json-schema solves the issue.

  • The issue goes away if the file is renamed from index.ts to index.js (but defeats the point, of course)

  • The issue is exactly the same without installing typescript

Some versions if it helps:

`-- [email protected]
  +-- @typescript-eslint/[email protected]
  | `-- @typescript-eslint/[email protected]
  `-- @typescript-eslint/[email protected]
    `-- @typescript-eslint/[email protected]  deduped

Most helpful comment

All 2 comments

This has been fixed upstream. Just reinstall XO and it should be fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sindresorhus picture sindresorhus  路  3Comments

tony-kerz picture tony-kerz  路  3Comments

sindresorhus picture sindresorhus  路  8Comments

sindresorhus picture sindresorhus  路  5Comments

SteveALee picture SteveALee  路  5Comments