3

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

peace.rider
  • 59
  • 2
  • 6
  • Possible duplicate of [Understanding npm package @-prefix: @angular/router](http://stackoverflow.com/questions/36667258/understanding-npm-package-prefix-angular-router) – str Mar 10 '17 at 12:54

2 Answers2

6

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

Paul
  • 35,689
  • 11
  • 93
  • 122
  • Its a big project . client is from china.. a lot of packages are defined using this package manager. I was thinking to remove them from private repo and make it local. Do you think its a nice idea.? – peace.rider Mar 14 '17 at 07:24
  • Yes, and I also would run them through snyk.io to see if there are known exploits against them. – Paul Mar 14 '17 at 17:55
  • It appears to be focused on having a company managed package repository. And yes, it appears to be mostly developed in and for China. It not too good at explaining itself. EG I can't find a man page nor reference to the flags. – dlamblin Aug 13 '21 at 19:15
3

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.

Community
  • 1
  • 1
str
  • 42,689
  • 17
  • 109
  • 127