Things Every Developer Should Know About package.json
Вставка
- Опубліковано 18 лис 2024
- This tutorial explains how you can configure your package.json file and the npm config settings to properly manage your project.
How to run npm scripts and pass arguments from the command line is also discussed.
Repo from video including scripts - bitbucket.org/...
I started watching this video with the intention of understanding the difference between package.json and package-lock.json but learnt a lot more than that. Thank you so much.
you can also get variables like this:
npm run task --var=data
console.log(process.env.npm_config_var); // data
Thanks for adding that note.
This kind of stuff is just eye opening.. Thank you so much!
lately syntax has changed a little,
now it is like this:-
npm config set init-license="MIT"
npm config set init-author-name="Steve Griffith"
...and as always, thanks for sharing and teaching !
Thanks for the detailed explanation. Your tuts are always an eye opener.
My dude! This was extremely well explained. Thankyou! Liked & Subbed
Great advice, excellent video.
Great videos Steve, i'm addicted to your channel! Thanks!
Great video. I always automatically click on notification to watch your video. Thanks for sharing
Thank you Steve for all your videos that you are doing. It helped me really much to understand lot of thing in JS. However, here I guess you omit the most import thing and it is talking about dependencies and packages itself :) You call this video "Things Every Developer Should Know About package.json", but I am not sure if the git command saved in the script is the most important think :)
I have other videos about git and dependencies etc. This video is a collection of things that many people are missing after they learn about git and npm basics,
your video is good, your voice is super Good, and your Name is extra super Good, and your Teaching is Mega fiber Goood
Thanks a lot. Great video!
Thanks for the explanation
I'm just starting with node.js and after setting the scripts I keep getting " npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. " before it prints what I needed.
Are you putting the flags "--global" or "--local" in your command to run a script?
The Gandalf of Javascript! Awesome vid, Steve. How bout one on package.json (common) scripts?
Please add that to my tutorial request video comments to remind me. - ua-cam.com/video/LCezax2uN3c/v-deo.html
Hi Steve, how can I add type:module to the package? Like where does it go?
It is a top-level property just like "name". "type": "module" can go anywhere at the same level as "name".
awesome tutor👏👍
im obviously missing somthing key here but when I delete and then run npm init --y I get hundreds of lines of json back, why would this be?
When the npm init command runs it is supposed to create the package.json file and it writes out the content of that file.
The content of the file is based on the global settings that have been set. If you have lots of settings it will write all those out.
nice bro! im newbie to npm. just want to know that we can change Script Object's keyword to a whatever string we want to tell npm to run the script or is it fixed?
btw, really like your voice / english accent. Where do you come from? ^^
subscribed!
You can name the scripts anything you want as long as they are inside "scripts"
I'm from Canada.
@@SteveGriffith-Prof3ssorSt3v3 thanks Steve. Im newbie to TS too & still strugling how to use the .d.ts file.
Im really confused on some points:
1. When to use import/export & when to use ///
@@PhongNguyen-tp7lg This tutorial is about package.json and has nothing to do with Typescript. I have not made any Typescript tutorials.
@@SteveGriffith-Prof3ssorSt3v3 haha my mistake, Ive watched so many videos for a clear exlaination ^^
process.argv is it inbuilt method to catch any arguments passed from command line?
Yes. nodejs.org/docs/latest/api/process.html#process_process_argv
@stevegriffith What happens when you also have -- inside the script? For example, "gitty": "node g.js -- ..."?
The double -- are for npm commands. You could use it with an npm command inside the script. The value is then going to be hard coded in the script and be the save every time.
Thanks for the quality info :)
Idk if you could find this helpful, but you can ctrl+l to clear the console instead of running 'clear'
Yep. But my students can see me type clear
@@SteveGriffith-Prof3ssorSt3v3 Ahh That's right :) My bad! Anyway thanks for the always good quality videos, I really enjoyed the pubsub pattern you uploaded :)
I missed the part where you explain how to make the `scripts` (like "steve") dependent on each other. E.g. how would you make the gitty command run everytime after/prior building
Here you go - ua-cam.com/video/kwn7tHJJoLA/v-deo.html
@@SteveGriffith-Prof3ssorSt3v3 Thank you! Very helpful!
Great lesson! The best, probably even the only relevant video I could find on the topic. It would be great if you proceeded with more examples of real life custom scripts.
I've got lots of those on my channel. :)
good work sir
You mind doing a video about static-link ?
Hey Steve, can you please tell how to add comments in package.json file if needed and what's the best way of doing that. I need to know if both single-line and multiline comments can work in package.json file or not
You cant add comments in JSON files
@@SteveGriffith-Prof3ssorSt3v3 thanks for clarifying Steve as I was going through some stackoverflow links but couldn't make out.
Thank you very much!!!!! Keep going! :D
Sir, i wanna know what is package-lock.json then?
In package.json we provide ranges for versions of dependencies.
package-lock.json records the exact version that is currently installed.
Thanks
npm init -y works too
yep. and npm init --yes
pretty advanced for me now..
In a few months it won't be.
very cool.
Thank You !!!!!!
me: thank you so much! this is just what I needed.
weebs: your voice turns me on senpai...
Love it
Awesome ++++++++++++
와... npm init 으로 이런 것 까지 할 수 있구나..
예
:)
My question/comment keeps getting deleted I don't know why. I'll try again, I am still confused as to the overall purpose of this file, who is the ultimate recipient of the file? Does NPM need this file and the info that it contains to make sure the stuff it downloads runs/updates smoothly, or, is the receipt suppose to be the programmer/Github user who needs that dependency information? In regards to the "sc....s" ( I think this word is why my comment keeps getting deleted) section in that file, that runs other commonly used "sc....s" by you, why not just use "b.t" files (the middle letter is a) - sorry, I think this is another word that keeps getting my comments deleted.
The package.json file is the settings file for a project controlled by npm or yarn. It includes information about the author, project name and versioning info, any connected repos, scripts for build and deploy, plus dependencies and dev dependencies. When you install an npm module into your project this file keeps track of that and its version.
It is a record for the developer of critical information about the project.
For anyone who clones the project on a new computer, they can run `npm install` and it will read this file and know what dependencies to install.
If you want, you can have your npm scripts run other things like batch files or shell scripts or terminal commands.
@@SteveGriffith-Prof3ssorSt3v3 Thank you for rewording the information in the video, plus adding additional detail. I understand the purpose and significance of the file now.
Sir, Great, sir you are! Can we implement these goodies for JS, for TypeScript you Greatio Sir in an extended G-Ratio! Gravitio! Gracias
Sorry for my royal English though
The package.json file relates to NPM more than the language(s) you are using in your projects. Not sure what you are looking to do with TypeScript.
Great video !!!
Thank you :) +1 sub !!!!
Was hoping for some words to package-lock.json
The lock file is just an automatically generated file that holds the specific version of installed dependencies.
Your voice is like dark chocolate
Bhai kya kar rha hai tu!!