Why Every Project Starts With package.json

Your check-setup.js already prints the setup values, and the team wants it to live in a proper project folder, onboarding-check/, that every new developer gets on day one. Make it in your home folder, as ~/onboarding-check. In Python, a folder with a script in it is all you’d need. A JavaScript project starts with one small file, and it changes how your script is read.

In this lesson, you’ll port one small change to the Python check, then turn the folder into a JavaScript project and see what that file changes. Start with the change.

Port the Folder Line the Python Way

The team’s Python check now stores the current folder in a name before printing it. In Python, assigning to a name is all it takes to create it:

Language: Python
import os
import platform
import sys

print("Python", platform.python_version())
print("OS:", sys.platform)
folder = os.getcwd()
print("Folder:", folder)

Port it line by line. In check-setup.js, the two new lines replace the old console.log("Folder:", process.cwd()); line:

Language: JavaScript
console.log("Node", process.versions.node);
console.log("OS:", process.platform);
folder = process.cwd();
console.log("Folder:", folder);

Run it in onboarding-check/, which has no package.json in it or above it. It prints the three setup values as before (the next steps and the reminder are left out here):

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.