Removing NPM artifacts problem

Hi all,
I was wondering if anyone had a similar problem and possibly a solution for it.

I have setup NPM repo with no problems. However when I delete artifact from it it is still shown when I run npm view artifact_name versions

Eg. If I have artifact @tools/tools with versions 1.0.0-alfa.1, 1.0.0-alfa.2, 1.0.0, 1.1.0-alfa.1 and I delete artifacts for versions 1.0.0-alfa.1 and 1.0.0-alfa.2 when I run “npm view @tools/tools versions” 1.0.0-alfa.1 and 1.0.0-alfa.2 are still listed. It doesn’t make any difference if I delete it manually or via groovy script.

I have tried to run Rebuild and Reconcile tasks but they didn’t help.

Any ideas?

Did you clear your local cache? I believe npm default pulls from there then goes to NXRM second.

Yeah. I have tried running “npm cache clean --force” but it didn’t help.

Did you try compacting your blobstore after delete?
PS: I haven’t seen this so just guessing.

Yes but that didn’t help either.
Thank you for trying to figure this out.

Hi everyone. Here is the latest update.
I have created fresh blob and tried adding and removing artifacts from it. Everything worked fine util I started groove script to remove assets

So it is a problem with groovy script after all. Now could someone, please, check what am I doing wrong

import org.sonatype.nexus.repository.Repository;
import org.sonatype.nexus.repository.storage.StorageFacet;
import org.sonatype.nexus.repository.storage.Query;

// Get a repository
def repo = repository.repositoryManager.get('Test');
// Get a repository
def tx = repo.facet(StorageFacet).txSupplier().get();

log.info('########################');
log.info("Repository: $tx");
log.info('########################');


try {
    // Begin the transaction
    tx.begin();
    tx.findAssets(Query.builder().build(), [repo]).each { asset ->
        if (asset.contentType() != "application/json") {
            tx.deleteAsset(asset);
        }
    }

    // End the transaction
    log.info("Committing deletes...")
    tx.commit();
    log.info("Committing deletes done.")
} catch (all) {
    log.info("Exception: ${all}")
    all.printStackTrace()
    log.info("Rolling back changes...")
    tx.rollback()
    log.info("Rollback done.")
} finally {
    tx.close();
    log.info("Transaction closed.")
}