Unlocking Package Secrets: The JSON Quest

Report a typo

Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!

Given a package.json file, how would you fill the blanks in the code to read the file and print out each dependency package name and version?

Fill in the gaps with the relevant elements
const fs = ('fs');
const packageJson = .(fs.('package.json', 'utf8'));
const dependencies = packageJson.dependencies;
console.log('Dependencies:');
 (let [package, version] of Object.entries(dependencies)) {
    console.log(`${package}: ${version}`);
}
stringifyJSONimportforyamlwhileparserequirereadFileSyncwriteFileSync

Create a free account to access the full topic