Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is cnpm? How to use it?

Tags:

node.js

npm

I have recently come across a project that extensively uses cnpm for package managing. I saw something like var a = require(@renil/a);

I have never seen something like this(@) in node when requiring a module. Can anybody help me out

like image 596
peace.rider Avatar asked Oct 15 '25 08:10

peace.rider


2 Answers

Those are actually two unrelated things. cnpm I had not heard of until I saw your question. After googling, it appears to be a Chinese maintained registry of node modules. Not sure what else is different but I'd probably stay away from it unless you know you need it.

The @ symbol in a package name has to do with scoping related modules. That's well covered in the npm docs: https://docs.npmjs.com/misc/scope

like image 113
Paul Avatar answered Oct 17 '25 03:10

Paul


These are scoped npm packages:

All npm packages have a name. Some package names also have a scope. A scope follows the usual rules for package names (url-safe characters, no leading dots or underscores). When used in package names, preceded by an @-symbol and followed by a slash, e.g.

@somescope/somepackagename

Scopes are a way of grouping related packages together, and also affect a few things about the way npm treats the package.

like image 35
str Avatar answered Oct 17 '25 02:10

str