0

I'm trying to publish package to npm but don't want that who using the package be able to see the code. How can I do this?

nirkov
  • 697
  • 10
  • 25

2 Answers2

1

Since npm is pretty much used to distribute JavaScript+CSS files, there is nothing you can do about it. Your code is going to be seen by whoever uses it or executes it.

You might be able to mitigate this somehow by using minifiers or obfuscators though.

Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
0

You can compile your code e.g. to dist folder and then run npm publish in the dist directory. Users then can see only what will be placed in the dist folder (compiled code). However, I think that this is not good practice.

You can also consider private npm packages to distribute your packages only to those who you want.

dev0experiment
  • 462
  • 1
  • 7
  • 22