0
votes

I have set up an Azure DevOps Artifacts Feed for NPM.
I followed the Instructions on https://docs.microsoft.com/en-us/azure/devops/artifacts/get-started-npm?view=azure-devops&tabs=windows

In the next Step, I wanted to publish packages from a “node_modules” Directory within a Visual Studio Project that got its packages from the Public source.

I thought if I run “npm publish” next to my custom “.npmrc” and “package.json” File it would publish all my libraries from the “node_modules” directory. Instead, it published my VisualStudio Project, which uses these libraries. It even followed the Git Ignore rules to not include the “node_modules” folder …

What would be the default way to publish the packages I depend on?
Do I have to write a script to do it for every single Package manually?

What do I with prebuild requiring packages?
After I ran a simple script a couple packages failed.

script:

for /d %i in (C:\Path\node_modules\*) do ( cd "%i" &  npm publish )

Error:

…
6 warn prepublish-on-install As of npm@5, `prepublish` scripts are deprecated.
7 warn prepublish-on-install Use `prepare` for build steps and `prepublishOnly` for upload-only.
8 warn prepublish-on-install See the deprecation note in `npm help scripts` for more information.
…
23 error code ELIFECYCLE
24 error errno 1
25 error [email protected] prepublish: `node scripts/generate-grammar.js < lib/grammar.pegjs > lib/generated-parser.js`
25 error Exit status 1
26 error Failed at the [email protected] prepublish script.
…

I saw these packages have their own sub packages : /

PS: My DevOps server and workstation do not have direct access to public Networks!

Thanks for any Help!

1

1 Answers

1
votes

What would be the default way to publish the packages I depend on?

You would not re-publish all your project's dependencies (= modules already published by other people) but let users of your module load them automatically by installing your project as a dependency.

Do I have to write a script to do it for every single Package manually?

Again, you would not publish other people's packages. You might use a bundler like Parcel, Rollup or Webpack to include all your dependencies' build code within your own build artefact, so it will not have external dependencies anymore. To tell your module's users about that fact, you would also have to tweak the package.json of your project (i.e. dependencies become devDependencies) and you also should take care of licenses (some of them require you to include legal headers inside your artefact, you publish other people's work under your own name). Furthermore you break with the modularity of the ecosystem, so don't expect overall efficiency.

PS: My DevOps server and workstation do not have direct access to public Networks!

I don't know if this was already possible at the time of your post: Within an Azure Feed you can define Upstream sources. So your Feed will provide a proxy to ( and cache for ...) npmjs.org, where the dependencies of your project are published / hosted (no need for direct access to public Networks because you will download from npmjs.org through your Feed).