reddark icon indicating copy to clipboard operation
reddark copied to clipboard

Missing package.json

Open LucaSchwan opened this issue 2 years ago • 7 comments
trafficstars

Hi, I just wanted to let you know that you only have your package-lock.json comitted.

LucaSchwan avatar Jun 08 '23 17:06 LucaSchwan

i don't seem to actually have a package.json at all image

Tanza3D avatar Jun 08 '23 17:06 Tanza3D

What commands are you using to run it?

LucaSchwan avatar Jun 08 '23 18:06 LucaSchwan

just node main.js

Tanza3D avatar Jun 08 '23 18:06 Tanza3D

@Tanza3D I see that a package.json file is missing. I can help with that. What packages are used in this project?

adeleke5140 avatar Jun 10 '23 16:06 adeleke5140

im pretty sure it's just socket.io and express, along with any packages they need. i'm unsure how package.json files help, so would be appreciated!

Tanza3D avatar Jun 10 '23 18:06 Tanza3D

im pretty sure it's just socket.io and express, along with any packages they need. i'm unsure how package.json files help, so would be appreciated!

Well, if a contributor wanted to clone the project locally, it would be hard to know which packages are required. A package json file helps out that information in one place.

From the npm docs:

A package.json file:

  • lists the packages your project depends on
  • specifies versions of a package that your project can use using semantic versioning rules
  • makes your build reproducible, and therefore easier to share with other developers

source

adeleke5140 avatar Jun 11 '23 15:06 adeleke5140

@Tanza3D it is pretty much common practice to provide a package.json with all the commands and dependencies (exact versions!) included in it so a Node.js dev can just run the usual npm install and npm start commands to get a dev setup up and running.

I can create a PR with the minimal set later but a package.json can basically be created with

npm init
# < at this point fill out the prompts, mostly defaults will work >
npm install -S express socket.io

And adding the following script to the "scripts" section:

"start": "node ./main.js"

Then check in the package.json. That's by the way where package-lock.json comes in as a shrink wrap for all dependencies. So I am surprised you didn't have one to begin with.

icedream avatar Jun 12 '23 07:06 icedream