Uploaded image for project: 'Artifactory Binary Repository'
  1. Artifactory Binary Repository
  2. RTFACT-27475

NPM postinstall for package not running when using Artifactory repository as npm registry

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Deferred
    • Affects Version/s: 7.42.5
    • Fix Version/s: None
    • Component/s: NPM
    • Labels:
    • Environment:

      Reproduced on 7.42.5 Cloud SaaS both with NPM 7.x and 8.x

      Description

      Problem Description:

      When using an Artifactory repository as an NPM registry, package does not run postinstall. The versions of NPM affected are 7 and 8. 

      Artifactory is also producing a different package-lock.json than the official registry would.

       

      Artifactory 7.42.5 package-lock.json:

       

      "0.0.4" : {
       "name" : "npm-lifecycle-hooks",
       "version" : "0.0.4",
       "directories" : { },
       "scripts" : {
      ...
       "preinstall" : "node script.js preinstall",
       "install" : "node script.js install",
       "postinstall" : "node script.js postinstall",
       "preuninstall" : "node script.js preuninstall",
       "uninstall" : "node script.js uninstall",
       "postuninstall" : "node script.js postuninstall",
      ...
       },
       "dist" : {
       "tarball" : "https://<Artifactory_URL>.jfrog.io/artifactory/api/npm/npm/npm-lifecycle-hooks/-/npm-lifecycle-hooks-0.0.4.tgz",
       "shasum" : "4058810dd84884826c251068fd88c867e6a7f0a2",
       "integrity" : "sha512-3XdFk6CsZGcoPNjm5iv25QVDCw3+3NlXwzw+PvMwxZoDEyQ6UlOXCRn03iWvbBYtJasqkwSEUL1TZxdc0JQiKQ=="
       },
      ...
       }

       

       

       

       

      NPM registry package-lock.json:

      "0.0.4": {
       "name": "npm-lifecycle-hooks",
       "version": "0.0.4",
       "dist": {
       "shasum": "4058810dd84884826c251068fd88c867e6a7f0a2",
       "integrity": "sha512-3XdFk6CsZGcoPNjm5iv25QVDCw3+3NlXwzw+PvMwxZoDEyQ6UlOXCRn03iWvbBYtJasqkwSEUL1TZxdc0JQiKQ==",
       "tarball": "https://registry.npmjs.org/npm-lifecycle-hooks/-/npm-lifecycle-hooks-0.0.4.tgz",
       "fileCount": 4,
       "unpackedSize": 5894,
       "npm-signature": "...",
       "signatures": [{
       "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
       "sig": "MEYCIQCJ5jHfvd2Wt3x1kO2n0lzKdW5Gxi0HrsrOGNnlr/1ROQIhAMngxark1ExhEjTD3hohgPVzmo/JgFncVicwZgKu23eh"
       }]
       },
       "hasInstallScript": true
       }

       

       

      Steps to reproduce:

      First used Artifactory repository as NPM registry.

      Example bash script provided by customer:

      //#!/bin/bashset -euo pipefail
      echo "node version: $(node -v)"echo "npm version: $(npm -v)"
      npm config set registry="https://<Artifactory_URL>/artifactory/api/npm/npm/"npm config set always-auth=true
      rm -rf node_modulesrm -f package-lock.json
      DEBUG=cypress:* npm install --legacy-peer-deps --foreground-scripts
      

       

      The above results in script running but no postinstall taking place:

       

      sh install-jfrog.sh       
      node version: v16.15.1
      npm version: 8.11.0
      
      
      up to date, audited 1 package in 56ms
      
      
      found 0 vulnerabilities
      

       

       

      When running a similar script with the official NPM registry:

      //#!/bin/bashset -euo pipefail
      echo "node version: $(node -v)"echo "npm version: $(npm -v)"
      npm config set registry="https://registry.npmjs.org"
      rm -rf node_modulesrm -f package-lock.json
      DEBUG=cypress:* npm install --legacy-peer-deps --foreground-scripts

       

      The postinstall runs correctly:

      sh install-npm.sh        
      node version: v16.15.1
      npm version: 8.11.0
      (##################) ⠹ reify:cypress: timing reifyNode:node_modules/lodash Comp
      > cypress@10.8.0 postinstall
      > node index.js --exec install
      

       

        Attachments

          Activity

              People

              Assignee:
              Unassigned
              Reporter:
              mauricew Maurice Washington
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: