# Removing NPM artifacts problem

**URL:** <https://community.sonatype.com/t/removing-npm-artifacts-problem/1409>\
**Category:** Sonatype Nexus Repository\
**Tags:** help\
**Created:** [March 8, 2019, 8:23am UTC](https://community.sonatype.com/t/removing-npm-artifacts-problem/1409 "2019-03-08T08:23:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zmitrovic](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/zmitrovic/32/527_2.png) [@zmitrovic](https://community.sonatype.com/u/zmitrovic)\
**Post date:** [March 8, 2019, 8:23am UTC](https://community.sonatype.com/t/removing-npm-artifacts-problem/1409/1 "2019-03-08T08:23:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jtom](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/jtom/32/68_2.png) [@jtom](https://community.sonatype.com/u/jtom)\
**Post date:** [March 8, 2019, 4:13pm UTC](https://community.sonatype.com/t/removing-npm-artifacts-problem/1409/2 "2019-03-08T16:13:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zmitrovic](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/zmitrovic/32/527_2.png) [@zmitrovic](https://community.sonatype.com/u/zmitrovic)\
**Post date:** [March 8, 2019, 8:22pm UTC](https://community.sonatype.com/t/removing-npm-artifacts-problem/1409/3 "2019-03-08T20:22:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jtom](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/jtom/32/68_2.png) [@jtom](https://community.sonatype.com/u/jtom)\
**Post date:** [March 8, 2019, 8:39pm UTC](https://community.sonatype.com/t/removing-npm-artifacts-problem/1409/4 "2019-03-08T20:39:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zmitrovic](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/zmitrovic/32/527_2.png) [@zmitrovic](https://community.sonatype.com/u/zmitrovic)\
**Post date:** [March 8, 2019, 8:57pm UTC](https://community.sonatype.com/t/removing-npm-artifacts-problem/1409/5 "2019-03-08T20:57:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zmitrovic](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/zmitrovic/32/527_2.png) [@zmitrovic](https://community.sonatype.com/u/zmitrovic)\
**Post date:** [March 11, 2019, 12:13pm UTC](https://community.sonatype.com/t/removing-npm-artifacts-problem/1409/6 "2019-03-11T12:13:50Z")

</div>

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.")
}
```
