2

I'm currently developing an Angular library package using ng-packagr. Apparently the built result is generated under './dist' folder and it contains all the files (including package.json, js, and d.ts files) that I want to publish to the npm server and that needs to be the root of my package.

Long story short, I want to be able to publish ./dist folder from the root folder with 'npm publish' command. Is it possible to set the default folder to publish (other than publishing the root folder)? I know we can use npm publish dist, but the thing is my teammates could accidentally do npm publish on the root folder and it makes the whole root folder get published.

  • You can change what `npm publish` does by editing package.json, assuming typical npm project structure. – stone Jan 19 '18 at 23:16
  • then you can write scripts in your `package.json` for everyone to use like `publish:npm publish dist` . – Sachin Jan 20 '18 at 02:42
  • @Sachin , tried it, but then it recursively published and eventually stopped due to same version error – Alfonso Pratama Jan 20 '18 at 03:34
  • I don't know the error but `publish: cd ./dist && npm publish` might help you. – Sachin Jan 20 '18 at 04:02
  • Above suggestions won't work for me: Couldn't find a package.json file (in the dist folder); even if I copy it there, it cascades with The specified path does not exist: 'tsconfig.build.json'. – Bob May 27 '20 at 14:32

0 Answers0