resolve: The test/resolver/malformed_package_json/package.json leads to an fatal error when starting meteor
Hello, I deleted the node_modules folder in my meteor app and made meteor npm install. After that the app can’t be started and ends up with the following error:
=> Started proxy.
/Users/jochen/.meteor/packages/semantic_ui/.2.2.6_5.h77ycc.hbbb4++os+web.browser+web.cordova/plugin.generateSemanticUi.os/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:165
throw error;
^
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at /Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/fs/tools/fs/optimistic.ts:321:17
at wrap.makeCacheKey (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/fs/tools/fs/optimistic.ts:36:15)
at recomputeNewValue (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/optimism/src/entry.ts:198:31)
at Slot.withValue (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/@wry/context/lib/context.esm.js:69:29)
at reallyRecompute (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/optimism/src/entry.ts:181:19)
at Entry.recompute (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/optimism/src/entry.ts:91:9)
at optimistic (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/optimism/src/index.ts:150:25)
at /Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/fs/tools/fs/optimistic.ts:366:19
at recomputeNewValue (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/optimism/src/entry.ts:198:31)
at Slot.withValue (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/@wry/context/lib/context.esm.js:69:29)
at reallyRecompute (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/optimism/src/entry.ts:181:19)
at Entry.recompute (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/optimism/src/entry.ts:91:9)
at optimistic (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/optimism/src/index.ts:150:25)
at find (/tools/isobuild/package-source.js:1344:30)
at /tools/isobuild/package-source.js:1400:27
at Array.forEach (<anonymous>)
at find (/tools/isobuild/package-source.js:1379:22)
at /tools/isobuild/package-source.js:1400:27
at Array.forEach (<anonymous>)
at find (/tools/isobuild/package-source.js:1379:22)
at /tools/isobuild/package-source.js:1400:27
at Array.forEach (<anonymous>)
at find (/tools/isobuild/package-source.js:1379:22)
at /tools/isobuild/package-source.js:1400:27
at Array.forEach (<anonymous>)
at find (/tools/isobuild/package-source.js:1379:22)
at find (/tools/isobuild/package-source.js:1411:25)
at /tools/isobuild/package-source.js:1423:34
at Object.withCache (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/fs/tools/fs/files.ts:1662:18)
at PackageSource._findSources (/tools/isobuild/package-source.js:1423:18)
at SourceArch.getFiles (/tools/isobuild/package-source.js:965:32)
at /tools/isobuild/compiler.js:406:23
at /tools/isobuild/compiler.js:186:28
at Object.withCache (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/fs/tools/fs/files.ts:1662:18)
at /tools/isobuild/compiler.js:185:11
at Function.each (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore-node-f-pre.js:1316:7)
at Object.compile (/tools/isobuild/compiler.js:180:5)
at /tools/isobuild/bundler.js:3291:24
at Object.capture (/tools/utils/buildmessage.js:283:5)
at bundle (/tools/isobuild/bundler.js:3237:31)
at /tools/isobuild/bundler.js:3180:32
at Slot.withValue (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/@wry/context/lib/context.esm.js:69:29)
at Object.withCache (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/fs/tools/fs/files.ts:1662:39)
at Object.bundle (/tools/isobuild/bundler.js:3180:16)
at /tools/runners/run-app.js:581:24
at Function.run (/Users/jochen/.meteor/packages/meteor-tool/.2.4.0_1.1npmc7f.35nt++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/tools/tool-env/tools/tool-env/profile.ts:289:14)
at bundleApp (/tools/runners/run-app.js:580:34)
at AppRunner._runOnce (/tools/runners/run-app.js:627:35)
at AppRunner._fiber (/tools/runners/run-app.js:949:28)
at /tools/runners/run-app.js:410:12
When I changed resolve/test/resolver/malformed_package_json/package.json to a well formed package.json by adding a ‘}’ everything is fine.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 11
- Comments: 39 (18 by maintainers)
Found this problem as well when running flow (https://github.com/flowtype/flow-bin) (latest version)
As a workaround I just added the file to the ignore list in the
flowconfigfileCan I ask why
resolvepublishes thetestdirectory in its package in the first place? In my opinion,test/should be in.npmignore.I found this issue because I was using a different tool that scans all package.json files under node_modules, and it crashed on
test/resolver/malformed_package_json/package.json. Yes, that tool needs to be fixed to ignore malformed input; howeverresolvecould also be a good NPM citizen by cleaning up its releases.I don’t agree with that statement, because in many cases it would require publishing nearly the entire contents of the project in the package. I believe making it easy to develop on the module is the job of the source repo, not the release artifacts. Regardless, this is not my package to maintain. Thank you for explaining the reasoning behind the decision, and thank you for all the maintenance work you do.
@robertfoobar that’s not been a best practice in the npm ecosystem, historically.
What I see is that it’s not caused problems, it’s exposed flaws in existing tools - flaws that have made them run MUCH slower than they need to, because they’re scanning WAY more files than they need to.
This issue unfortunately seems to cause a lot of avoidable hassle. It cost us almost one day to analyse.
I also don’t agree. Shipping test code is considered a weakness in software development. There’s even a CWE for that:
Although you’re IMO right that affected third party apps should be implemented more resiliently, this probably is not going to happen soon.
@ljharb Thank you.
I saw this statement repeated several times in this thread. Where does this comes from? Is it recommended somewhere in the Npm documentation?
This is an opinion strongly focused on frontend. The backend applications do not use bundles; bundling do not bring any benefit to them. These tests use space, trigger security issues and all the annoyances discussed here and do not bring any benefit.
This statement cannot be proved without running the code and taking all possible paths. The security scanning tools are correct. All files included in the application must be checked.
It does! But like I mentioned this is a subpackage of a package that is imported. So as far as the package tree is concerned, this is included.
Subpackages are importable still though. Here’s an article talking about them. And from a vulnerability perspective, it would leave a hole in the protection of the scanner if it just allowed anything to be in subpackages.
To be clear it’s using the package.json file as one of many inputs to evaluation. It doesn’t need it to be there and you can ignore parsing errors, but I would rather not so that I see any other issues that come up. Which, seems to be the concern of others on this thread as well
I also just want to take a moment to thank you for your work on this package. I know that Open Source development can be pretty thankless, and I just want to say I appreciate the time and care put into these packages that make the whole ecosystem better for everyone.
While true, to know what files will be executed at runtime is a hard problem to solve, no?
To my knowledge, all package.json files. And it does because you can import this sub-package using
require("resolve/test/resolver/malformed_package_json"). Just in case we do, it gets scanned.failed to parse node_modules/resolve/test/resolver/malformed_package_json/package.jsonfailed to parse node_modules/eslint-plugin-react/node_modules/resolve/test/resolver/malformed_package_json/package.json"eslint-plugin-react": "^7.30.1"This was absolutely hilarious, spent half an hour on it. Thanks for the laughs, added to my comedy gold bookmarks 👍🏽
@ljharb I’d love to understand your position on this a bit better. I can I see the benefit in the sense that users could run tests against the package locally to get confidence of its code quality, but it seems like it comes with some serious tradeoffs, namely increased bundle size and issues like this one. In my view it’s very easy to get the tests for the package by cloning the repo instead. I would imagine the number of people who would prefer a small npm bundle size would be much higher than the number of people who would appreciate tests to be included. Am I missing some other angle?
@ngraef because
npm explore foo && npm install && npm testshould always work.Good npm citizens publish their tests, in my opinion.
Good point.