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

Npm artifacts resolved from a local repository have different package.json than that of the default npm registry

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 4.9.0, 6.1.0
    • Fix Version/s: 6.3.0
    • Component/s: None
    • Labels:
      None

      Description

      Some files do not have the same package.json metadata in the .npm folder after Artifactory calculates the metadata in a local npm repository compared to that of http://registry.npmjs.org.

      This can be reproduced with the package oracledb, which is attached. The package.json found in the default npm registry (see package.json) have a "install": "node-gyp rebuild" step:

      "scripts":

      { "test": "mocha --opts test/opts/mocha.opts", "posttest": "node test/opts/versions.js", "testwindows": "mocha --opts test\\opts\\mocha.opts && npm run posttest", *"install": "node-gyp rebuild"* }

      while the one that is created in a local repository (see package-artifactory-generated.json) doesn't:

       "scripts":

      { "test": "mocha --opts test/opts/mocha.opts", "posttest": "node test/opts/versions.js", "testwindows": "mocha --opts test\\opts\\mocha.opts && npm run posttest" }

       

      In this case, it causes oracledb not to run node-gyp rebuild.

       

      Steps to reproduce:
      -Download oracle db from http://registry.npmjs.org with a remote npm repository. (or find necessary files attached)
      -Copy or upload oracledb-1.13.1.tgz, as well as nan.tgz to a local npm repo (we'll call it npm-local). The metadata should be created by Artifactory. (nan is a dependency of oracledb)
      -Create a test directory with the below package.json:

      {
      "name": "test",
      "version": "2.0.0",
      "description": "adf2",
      "main": "index.js",
      "scripts":

      { "test": "echo \"Error: no test specified\" && exit 1" }

      ,
      "dependencies":

      { "oracledb": "1.13.1" }

      ,
      "author": "MEME2",
      "license": "ISC"
      }
      -Inside the test directory, run "npm install --production" against npmjs (or an Artifactory remote repo proxying npmjs) 
      -Notice the node-gyp rebuild step:
      oracledb@1.13.1 install /home/matthew/Downloads/testpackage/node_modules/oracledb
      > node-gyp rebuild

      -run "rm -Rf node_modules" in the test dir, and "npm cache clear"
      -run "npm install --production" inside the test directory again, this time resolving from npm-local (so that it uses Artifactory's generated package.json for oracledb). Notice it does not have the node-gyp rebuild step.

      Workaround:

      -Replace the Artifactory created package.json in npm-local/.npm/oracledb/ with the one from http://registry.npmjs.org (the package.json is attached)
      -call npm install --production again and notice the node-gyp rebuild step now that the scripts have it

        Attachments

        1. nan-2.5.1.tgz
          65 kB
        2. oracledb-1.13.1.tgz
          122 kB
        3. package.json
          45 kB
        4. package-artifactory-generated.json
          2 kB

          Activity

            People

            • Assignee:
              nadavy Nadav Yogev
              Reporter:
              mattheww Matthew Wang
            • Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: