Impossible to run `preview` because of linting errors
- Platform: Darwin quack.local 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64
- Mercury Parser Version: 2.1.1
Expected Behavior
I had just finished my first custom extractor and wanted to run ./preview [url of page] to make sure it works fine and extract the correct stuff, but it never got there because of the issue explained below.
Current Behavior
It seems from the output that Mercury needs to be rebuilt because the console output shows this:
$ ./preview https://www.la-croix.com/Famille/Education/enseignants-francais-sentent-pas-assez-formes-2019-06-19-1201029921
Rebuilding Mercury
error Command failed with exit code 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @postlight/[email protected] build: `yarn lint && rollup -c && yarn test:build`
npm ERR! Exit status 1
... more output skipped ...
Looking further into the problem, it appears that it runs first eslint . --fix (via yarn lint). Running this on the command line, I get these errors in the output:
$ eslint . --fix
/Users/jakob/Projects/mercury-parser/src/cleaners/index.js
6:1 error Dependency cycle detected import/no-cycle
/Users/jakob/Projects/mercury-parser/src/cleaners/title.js
5:1 error Dependency cycle detected import/no-cycle
/Users/jakob/Projects/mercury-parser/src/extractors/generic/content/scoring/index.js
6:1 error Dependency cycle detected import/no-cycle
8:1 error Dependency cycle detected import/no-cycle
9:1 error Dependency cycle detected import/no-cycle
10:1 error Dependency cycle detected import/no-cycle
11:1 error Dependency cycle detected import/no-cycle
12:1 error Dependency cycle detected import/no-cycle
13:1 error Dependency cycle detected import/no-cycle
/Users/jakob/Projects/mercury-parser/src/utils/dom/index.js
5:1 error Dependency cycle detected import/no-cycle
15:1 error Dependency cycle detected import/no-cycle
✖ 11 problems (11 errors, 0 warnings)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
As can be seen a number of cyclic dependency errors are detected. I'm unsure why I'm encountering these. I couldn't find any other ticket reporting this issue. :-(
Steps to Reproduce
See description above.
I tried running ./preview with another URL just to make sure, but (of course) the same error occurred.
Hi @jfix,
I attempted to reproduce the issue on v2.1.1 you're seeing with the url you provided. Everything seems to be in working order. See images below. I would suggest trying the following:
- kill off any existing node processes that may be causing a conflict
- clean your npm cache
- try deleting the lock file and node_modules directory and then reinstall packages w/ either npm or yarn
JSON Output

Preview

I've done what you've suggested, but am encountering the same issue as before :-(
Make sure no other node processes are running:
quack:~ jakob$ ps aux | grep node
jakob 55884 0.0 0.0 4268040 788 s000 S+ 12:15am 0:00.00 grep node
Empty the npm cache (although apparently no longer necessary as per https://docs.npmjs.com/cli/cache.html):
00:18 $ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
✔ ~/Projects/mercury-parser [feat-la-croix-com-extractor L|✚ 1…3]
Remove node_modules directory and the package-lock.json (as I was using npm before):
✔ ~/Projects/mercury-parser [feat-la-croix-com-extractor L|✚ 1…3]
00:21 $ rm -rf node_modules/ package-lock.json
✔ ~/Projects/mercury-parser [feat-la-croix-com-extractor L|✚ 1…2]
00:22 $
Install from scratch using yarn:
✔ ~/Projects/mercury-parser [feat-la-croix-com-extractor L|✚ 2…2]
00:22 $ yarn install
yarn install v1.17.3
info No lockfile found.
[1/5] 🔍 Validating package.json...
[2/5] 🔍 Resolving packages...
warning turndown > jsdom > [email protected]: use String.prototype.padStart()
warning @babel/[email protected]: 🚨 As of Babel 7.4.0, this
package has been deprecated in favor of directly
including core-js/stable (to polyfill ECMAScript
features) and regenerator-runtime/runtime
(needed to use transpiled generator functions):
> import "core-js/stable";
> import "regenerator-runtime/runtime";
warning [email protected]: WARNING: This project has been renamed to babel-plugin-module-resolver. Install babel-plugin-module-resolver for new features
warning jest > jest-cli > prompts > [email protected]: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
warning karma > log4js > [email protected]: CircularJSON is in maintenance only, flatted is its successor.
[3/5] 🚚 Fetching packages...
[4/5] 🔗 Linking dependencies...
warning " > [email protected]" has unmet peer dependency "request@^2.34".
warning "request-promise > [email protected]" has unmet peer dependency "request@^2.34".
warning " > [email protected]" has incorrect peer dependency "babel-plugin-module-resolver@^2.3.0".
[5/5] 🔨 Building fresh packages...
success Saved lockfile.
✨ Done in 68.87s.
Try `./preview' again:
✔ ~/Projects/mercury-parser [feat-la-croix-com-extractor L|✚ 2…2]
00:23 $ ./preview https://www.la-croix.com/Famille/Education/enseignants-francais-sentent-pas-assez-formes-2019-06-19-1201029921
Rebuilding Mercury
error Command failed with exit code 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @postlight/[email protected] build: `yarn lint && rollup -c && yarn test:build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @postlight/[email protected] build 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! /Users/jakob/.npm/_logs/2019-08-20T22_24_09_679Z-debug.log
child_process.js:660
throw err;
^
Error: Command failed: MERCURY_TEST_BUILD=true npm run build
error Command failed with exit code 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @postlight/[email protected] build: `yarn lint && rollup -c && yarn test:build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @postlight/[email protected] build 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! /Users/jakob/.npm/_logs/2019-08-20T22_24_09_679Z-debug.log
at checkExecSyncError (child_process.js:621:11)
at execSync (child_process.js:657:15)
at Object.<anonymous> (/Users/jakob/Projects/mercury-parser/preview:20:3)
at Module._compile (internal/modules/cjs/loader.js:777:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:840:10)
at internal/main/run_main_module.js:17:11 {
status: 1,
signal: null,
output: [
null,
<Buffer 0a 3e 20 40 70 6f 73 74 6c 69 67 68 74 2f 6d 65 72 63 75 72 79 2d 70 61 72 73 65 72 40 32 2e 31 2e 31 20 62 75 69 6c 64 20 2f 55 73 65 72 73 2f 6a 61 ... 1137 more bytes>,
<Buffer 65 72 72 6f 72 20 43 6f 6d 6d 61 6e 64 20 66 61 69 6c 65 64 20 77 69 74 68 20 65 78 69 74 20 63 6f 64 65 20 31 2e 0a 6e 70 6d 20 45 52 52 21 20 63 6f ... 450 more bytes>
],
pid: 56808,
stdout: <Buffer 0a 3e 20 40 70 6f 73 74 6c 69 67 68 74 2f 6d 65 72 63 75 72 79 2d 70 61 72 73 65 72 40 32 2e 31 2e 31 20 62 75 69 6c 64 20 2f 55 73 65 72 73 2f 6a 61 ... 1137 more bytes>,
stderr: <Buffer 65 72 72 6f 72 20 43 6f 6d 6d 61 6e 64 20 66 61 69 6c 65 64 20 77 69 74 68 20 65 78 69 74 20 63 6f 64 65 20 31 2e 0a 6e 70 6d 20 45 52 52 21 20 63 6f ... 450 more bytes>
}
✘-1 ~/Projects/mercury-parser [feat-la-croix-com-extractor L|✚ 2…2]
00:24 $
The debug log referenced above is here: 2019-08-20T22_24_09_679Z-debug.log
I was quite hopeful earlier, but now I'd be glad for some more ideas! ;-)
Hmm, a couple more quick suggestions:
- double check your node version
- clone another copy of the repo and do another fresh install, see if it may be something within your custom extractor.
- try installing w/ npm instead of yarn (shouldn't matter, but worth trying)
- I ran the same eslint command and did not receive the same errors you did, so perhaps try temporarily emptying the eslint-related commands in your package.json scripts section.
Are you able to run the parser globally?
# Install Mercury globally
yarn global add @postlight/mercury-parser
# or
npm -g install @postlight/mercury-parser
# Then
mercury-parser https://postlight.com/trackchanges/mercury-goes-open-source
@jfix I'm working on upgrades the packages in this repo and now seeing the ELIFECYCLE issues, it appears related to rollup being outdated. Will follow-up w/ an update once I get the fix merged.
Thanks @mtashley for continuing to look into my problem! I've been able to install mercury-parser globally using npm, but am still encountering the previously reported errors, so I'm kind of glad you do, too! I'll be waiting for an update (don't worry, not impatiently!) and would be happy to do testing when/if required.