NPM is the most widely used package manager for NodeJS. It has more than 600,000 packages with hundreds of millions of downloads per day.
NodeJS uses directory hierarchy for finding modules. Specifically, it searches node_modules
subdirectory in the current folder or its parent folders for the required modules.
Naming packages is important for several reasons. Firstly, your package name must be unique. Secondly, your chosen name should be expressive for your package.
Now this leads to a lot of problems. Consider, for example, that you want to create a package named dom
for working with the document object model. Chances are someone has already put a package with that name on npm
. On the other hand, let's assume that you need a package for working with DOM. Can you offhandedly run npm install dom
and expect to find what you want?
As you can see, a simple name cannot satisfactorily define a package. What we need is some sort of namespace. Scoped packages give you this functionality. Instead of dom
, you can name your package @yourname/dom
. This prevent name clashes and defines your dom
package more thoroughly.
In order to create a scoped package, add --scope yourname
to npm init
command:
npm init --scope=yourname
This adds a line like the following to your package.json
file:
{
"name": "@yourname/dom"
}
When requiring scoped packages, you must use the complete name:
const dom = require("@yourname/dom");
The same applies to including the package as a dependency in package.json
:
{
"dependencies": {
"@yourname/dom": "^1.0.0"
}
}
In npm, scoped packages are private by default (and they require paid membership in npmjs.com). If you want to publish your scoped package publicly, you should set the public access option when publishing it (only the first time):
npm publish --access=public
When installing scoped packages, you must use the complete name:
npm install "@yourname/dom"
After installing a scoped package, npm
creates a subdirectory @yourname
under node_modules
and puts your package in that folder:
node_modules
│
└──@yourname
│
└──dom
│
├──package.json
└──index.js
Namespacing is very useful for differentiating packages. Scoped NodeJS packages are already being used in many popular JavaScript projects.
Don't miss out on my Learn Python Series @Ghasem :-)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Of course. Thank you for letting me know.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@yourname/dom ... yep! thanks for the info ! useful
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I'm not in a javaScript but have a plan to learn it in the future,
A little c # programmer here :p
the package name is one of the major parts of programming blocks,
It makes us remember what we are doing.
Thanks for sharing this amazing knowledge with us brother.
Yeah, we can say namespace is the backbone of nodejs packages.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice post. That idioms time u were 3-4 times in a day. Now r u busy sir ???
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice post mashti
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@ghasemkiani - I am not sure if you are still posting or not?
2 things:
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you. Currently, I am preparing some educative posts on JavaScript programming. And thanks for the link on Rumi. I will definitely check it out!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Looking forward to your next educative post @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Excellent job. Learning new things. Thank you for this opportunity.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good post, can you please share post on selenium?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
good post mashti:) fallow kon please
support me i will supportet mikonam
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good job.Keep it up
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hi @ghasemkiani. I'm currently on a project of creating a local exchange of steem to my local currency(Ghana Cedis) but i have no idea of how to call a user's steemit info when he/she logs in into that site with their steemit account. Thought you could be the best person to help.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
If you use JavaScript, Steem.js is the official JavaScript library for the Steem blockchain.
If by user info you mean the profile characteristics of the user, you can use the
steem.api.getAccounts
method. The profile info is in thejson-metadata
field.Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks very much. I’ll try my hands on that.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Can you help me? @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks your stopping my bog and upvote my post, now i,am follow you, next if your new post i can stopping your blog again.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for sharing this! I installed NodeJS on FreeBSD 2 years ago for a developer but i wasn´t fully aware of its structure and capabilities! Am following you, you have my upvote and resteem for this post of yours! Greetings from Mérida, Yucatán, México the Maya Land
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Great information sir @ghasemkiani . Im very sorry actually your topic very difficult but i will try my best .
Stay blessed and stee on!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hi my brother
Teach me to use better esteem and useful
In order to get more votes like you.
Thank you
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice post!!!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you very much for coming my post sir @ghasemkiani . Sir upload new post . Im waiting your new post .
Stay blessed
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Buena publicacion
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
NPM is greate;i use it for manage angular packages.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you. And happy New Year! Hope to see you soon.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
informative and great post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Excellent post thank you for shere this info.....??
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Very good information about npm .
I had no knowledge about and you did analysis about it . Thank you so much.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thanks for sharing this post..
i appreciate your post.. best of luck..
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good job. Keep it up. Which programming language did you like most?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Useful content sir... appreciate your work...👍
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You are so intelligent @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@ghasemkiani OMG. Now you start practicing node.js? You are genius.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice post ..thanking for learning post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
resteem
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for your javascript post . I will waiting for your next post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
very well post great writing D:)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice post keep it up.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Nice post.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@ghasemkian u are a genius
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
fallow and support me mashti :)
i will fallow and support you very soon
i need your helping
thank you
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Leaving comments asking for votes, follows, or other self promotional messages could be seen as spam.
Your Reputation Could be a Tasty Snack with the Wrong Comment!
Thank You! ⚜
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good post @ghasemkiani
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
its a great info...
thanks for sharing....
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
thanks for sharing....
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This great post i appreciate your post....thanks for sharing....
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
well done ghasemkiani!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Scopes are a way of grouping related packages together, and also affect a few things about the way npm treats the package.
Each npm user/organization has their own scope, and only you can add packages in your scope. This means you don't have to worry about someone taking your package name ahead of you. Thus it is also a good way to signal official packages for organizations.
Scoped packages can be published and installed as of
npm@2 and are supported by the primary npm registry. Unscoped packages can depend on scoped packages and vice versa. The npm client is backwards-compatible with unscoped registries, so it can be used to work with scoped and unscoped registries at the same time.
Thanks for the post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Your incredible post and the pictures you post are very inspiring to my mind, please support me and give me a lot of upvote and follow me include your comment, hopefully useful, go ahead and hope you succeed in steemit. by @zayanfaruk.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Amazing post......i like your post..... thanks for sharing......
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
what's going on mr.hadipedia???
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
amazing post my dear friend
If you like you can see wonderful places in our country and I will be so happy if I know your comments about my posts dear
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
a very satisfying post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I love programming
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
your ppst is very informative.........i like this post.........
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice post with beautiful words.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
When you copy/paste or repeatedly type the same comments you could be mistaken for a bot.
Tips to avoid being flagged
Thank You! ⚜
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
that's pretty cool to know
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
this is really cool work your shared and all those codes helped me to learn more about it thanks for sharing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit