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
- download the file from the gist
- 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
- chore: bump dependencies * Update ng deps to 6.x * Fix ngrx deps to 6.0.0-beta.3 * Update rxjs to 6.x * Update ts to 2.7.x * Add rxjs-compat to devDeps in order to the following: https://github.com/... — committed to jotatoledo/ngrx-actions by deleted user 6 years ago
- Add rxjs-compat due to lint-staged issue. See https://github.com/okonet/lint-staged/issues/416 for details. — committed to antonve/srs-app-archived by blindbox 6 years ago
- add rxjs-compat due to lint-staged issue. See https://github.com/okonet/lint-staged/issues/416 for details. — committed to antonve/srs-app-archived by blindbox 6 years ago
- fix naming issue and cli issues — committed to BuildTeamDev/tokenbb-web-client by marvin-bitterlich 6 years ago
- :bug: Upgraded dependencies to fix bugs See https://github.com/okonet/lint-staged/issues/416 and https://github.com/facebook/jest/issues/6766 — committed to and-digital/and-workshop-corejs by andgreendigital 5 years ago
- Upgrade lint-staged this prevents errors from rxjs upgrade https://github.com/okonet/lint-staged/issues/416#issuecomment-458830064 — committed to aragon/client by 2color 5 years ago
- Upgrade lint-staged (#646) This prevents errors from rxjs upgrade https://github.com/okonet/lint-staged/issues/416#issuecomment-458830064 — committed to aragon/client by 2color 5 years ago
- Upgrade lint-staged (#646) This prevents errors from rxjs upgrade https://github.com/okonet/lint-staged/issues/416#issuecomment-458830064 — committed to aragon/client by 2color 5 years ago
- install rxjs-compat to workaround an issue similar to this https://github.com/okonet/lint-staged/issues/416 — committed to levelkdev/futarchy-app by mikec 5 years ago
- ➖Remove unused dependencies Also updated lint-staged because of this bug: https://github.com/okonet/lint-staged/issues/416 — committed to AckeeCZ/node-template by deleted user 3 years ago
- fix lint-staged error After package-lock update got following error: husky > pre-commit (node v20.9.0) ... Error: Cannot find any-observable implementation nor global.Observable. You must install poly... — committed to markustimma/react-good-form by markustimma 5 months ago
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
to8.1.1
solved the issueIt 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
thenyarn 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 deletingpackage-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 dependenciesI 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
Not sure where it’s coming from since I don’t have
.nvmrc
there 😕Full output here:
/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)
It’s not that simple. Please see #426