lint-staged: Error thrown running with the RxJS@6.0.0-beta.0 (mini repo included)

Description

Steps to reproduce

mini repo at https://gist.github.com/ztan/adefcaf938a4df7ef92b62c4738b7736

  1. download the file from the gist
  2. run
npm run test

Debug Logs

C:\work\projects\sandbox\lint-staged-test> npm run test

> lint-staged-test@0.0.0 test C:\work\projects\sandbox\lint-staged-test
> lint-staged -d

  lint-staged:bin Running `lint-staged@7.0.0` +0ms
C:\work\projects\sandbox\lint-staged-test\node_modules\any-observable\register.js:29
                throw new Error('Cannot find any-observable implementation nor' +
                ^

Error: Cannot find any-observable implementation nor global.Observable. You must install polyfill or call require("any-observable/register") with your preferred implementation, e.g. require("any-observable/register")('rxjs') on application load prior to any require("any-observable").
    at loadImplementation (C:\work\projects\sandbox\lint-staged-test\node_modules\any-observable\register.js:29:9)
    at register (C:\work\projects\sandbox\lint-staged-test\node_modules\any-observable\loader.js:32:18)
    at Object.<anonymous> (C:\work\projects\sandbox\lint-staged-test\node_modules\any-observable\index.js:2:39)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lint-staged-test@0.0.0 test: `lint-staged -d`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lint-staged-test@0.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ztan\AppData\Roaming\npm-cache\_logs\2018-03-23T02_28_36_078Z-debug.log
expand to view
COPY THE DEBUG LOGS HERE

Environment

  • OS: Windows 10
  • Node.js: 8.9.1
  • lint-staged: 7.0.0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 10
  • Comments: 35

Commits related to this issue

Most upvoted comments

It seems Listr depends on RxJS, and because it hasn’t been updated to support RxJS 6, a compatibility package rxjs-compat is required. Once this package is installed, the issue goes away.

Upgrading lint-staged to 8.1.1 solved the issue

It appears my issue was in yarn. Running a yarn cache clean before nuking my node_modules/etc seems to have cleaned everything up.

yarn cache clean then yarn add --dev lint-staged@^7.2.0 worked for me.

Still have this issue

I appear to be pulling in lint-staged@^7.2.0, listr@^0.14.1, and any-observable@^0.3.0, which leads to me believe this should be working?

If I can’t get this sorted out soon, I’ll try to throw together a minimal failing example. Thanks for the quick reply!

@0xc0d3r thanks! That seems to fix it for me as well.

@SamVerschueren thanks! Deleting node_modules did not do the trick, but deleting package-lock.json did.

PS: any-observable was already on the latest version, so it was something else. Here is the commit with the package-lock.json changes.

Updated to latest list-staged version solved it for me.

I’ve run into the same error message, but when using @pnpm to install lint-staged.

See here: https://github.com/pnpm/pnpm/issues/1496

For me this issue came out of the blue after adding “rxjs” as dev dependency (needed it for some unit tests)

I fixed it by adding rxjs-compat as dev dependency as well.

So it looks like husky or any-observable is obscurely trying to find rxjs in the node_modules, working correctly (maybe polyfilling) if it is not installed, but breaking as soon as rxjs is added to the dependencies

I just ran into this as well on https://github.com/okonet/eslint-config-okonet

Node: 10.3.0

BUT then I run pre-commit I see

husky > npm run -s precommit (node v8.11.2)

Not sure where it’s coming from since I don’t have .nvmrc there 😕

Full output here:

``` Projects/OSS/eslint-config-okonet on  feature-upgrade-all [+] is 📦 v0.0.0-development via ⬢ v10.3.0 ➜ gc husky > npm run -s precommit (node v8.11.2)

/Users/okonet/Projects/OSS/eslint-config-okonet/node_modules/any-observable/register.js:29 throw new Error(‘Cannot find any-observable implementation nor’ + ^

Error: Cannot find any-observable implementation nor global.Observable. You must install polyfill or call require(“any-observable/register”) with your preferred implementation, e.g. require(“any-observable/register”)(‘rxjs’) on application load prior to any require(“any-observable”). at loadImplementation (/Users/okonet/Projects/OSS/eslint-config-okonet/node_modules/any-observable/register.js:29:9) at /Users/okonet/Projects/OSS/eslint-config-okonet/node_modules/any-observable/loader.js:30:18 at Object.<anonymous> (/Users/okonet/Projects/OSS/eslint-config-okonet/node_modules/any-observable/index.js:2:39) at Module._compile (module.js:652:30) at Object.Module._extensions…js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18)

husky > pre-commit hook failed (add --no-verify to bypass)

</details>

It’s not that simple. Please see #426