How to publish zip file using npm publish? - npm

I am currently publishing my project to an artifactory registry as a .tgz file. I am working on implementing a CD step that will pull the file from artifactory and put it into an in-house application.
Unfortunately the application only accepts zip files. Is there a way I can specify the format of the file that npm publish puts my application in before sending it to my artifactory registry? I don't see any options for this in the documentation, but it seems like it should be possible unless I'm missing something.

Related

Cannot access npm package stored in azure artifact via npm install

I have a private package which are types produced by a backend C# application. Those types are pushed to a sharedTypes directory and published to Azure via npm publish configuration as shown in this tutorial.
Everything works great, until I try to actually install the package. The only errors I get back seem to be a e404 not found, even though I've placed a .npmrc file at my $home directory as well as inside of the project that I am trying to inject it into. Followed the directions by copying the credentials into the .npmrc file as shown inside of Azure.
Are there additional settings I need to set to be able to npm install if from my development machine? Not sure exactly what I am missing.

Azure DevOps Artifacts not including all packages?

I have a feed configured in Azure DevOps, with an upstream feed of https://registry.npmjs.org.
When I run yarn from my terminal, all of the packages in my package.json and their dependencies are correctly downloaded to my machine, but only a subset are added to my feed (59 packages listed in the feed vs. 1029 in my node_modules folder). There are 17 packages explicitly listed in my package.json.
I need to have all of the packages/dependencies stored in the DevOps feed so that we can restrict allowable packages and versions. We want to prevent regular developers from adding new packages or changing package versions on a project - letting them just pick from the "approved" packages/versions (which we do by requiring them to use a different feed which is configured with only our "restricted" feed as its upstream source). If there's another way to do this, that's fine.
Once you consume a package from an upstream source once, a copy of it is always saved in your feed.
This may be caused by the cache, If the package is already cached locally. It will not download again and save the package in your feed.
Please run the command npm cache verify, you can see the package path along with other details. Clean the package cache and try it again, it should save all packages downloaded from the upstream feed.
In addition, please also try to run the project via hosted agent. With Microsoft-hosted agents, each time you run a pipeline, you get a fresh virtual machine.
I hope it can help you.

Is there a way in Verdaccio to generate package.json files based on what it has in it's storage?

I'm publishing angular packages to Verdaccio to use inside the company. Suddenly, I found out that one of my package is missing, when I run npm install it gives me an error saying Can not find that specific module. When I checked the verdaccio UI it was not there as well then I checked the server where Verdaccio is hosted, there was no package json file inside that package folder but all the .tgz files are there.
all the tgz files
Is there a way to redo all of it's package.json files based on what it has in it's storage?
Verdaccio version -4.0.4

How to compile vuejs source code to a single html file?

I have a simple vuejs project, which does not need to communicate with server. I need to pass this project to someone does not know software engineering, so I cannot have him install nodejs and run npm run dev to run this project. Is there any way to compile this project to a single html file, so he can just open this file in chrome and run it?
If you just want to show him the project (and don't let him edit it), the obvious solution is to create a build (running npm run build), put it on a test server and give him the domain name. Another possibility is to send him (e.g. via mail, zipped) the content of the dist folder after a build (the index.html and the static folder).

About publishing Angular 2 application

I have developed an Angular 2 application using npm, As a fresher,I don't know some ways like below.
When I publish I used npm publish so that it publish the application in npm account in the web.
So here, is there any way to publish our app in the localhost,because I don't want to use npm account and I just need to avoid node_modules folder on publishing ?
If any other way,that can be used to publish the Angular2 Application in local other than npm, let me know.I try that.
If it is not possible to publish the application without npm web account, Kindly let me know please .
Excuse mistakes,If any.Thanks in adv :)
npm publish is to make a library package available to other for free use.
That's not what you use for making a web application available. This is called deployment.
For deployment you usually execute a build step that transpiles TS to JS, and combines them into a single file to reduce the number of requests the browser needs to make in order to get all source files of your application. It may also inline component HTML and CSS. This build step can also minify and mangle to JS code to reduce the resulting file size even more.
The resulting output can just be copied to any directory that any web server is able to serve to a browser either on your local machine or at some machine of a web hosting provider.
There are different ways to build your application depending on your setup.
See for example How to deploy Angular 2 application developed in Typescript to production?
You need browserify, that's all
browsers need references to all js files to be put in the html, they don't understand node's require() method that forms modules dependencies
what browserify does is traversing the entire dependency graph of your project, recursively bundling up all the required modules starting at the given root into a single js file
install it by node package manager
npm install -g browserify
use it to bundle all needed modules staring at main.js
browserify main.js -o bundle.js
now put a single script tag into your html
<script src="bundle.js"></script>
as far as i know, node_modules contains dependencies for typescript transpilers and few others. so it will not be possible to publish an app without using node_modules.
perhaps you can try using Plnkr or jsFiddle
where you can make imports online using cdn links for node_modules and publish your app.
it will be easy compared to other alternatives.
hope this helps.