andrewrk / node-s3-client

high level amazon s3 client for node.js
MIT License
1k stars 303 forks source link

Can't resolve 'module' in 'node_modules/natives' #213

Open unkownara opened 5 years ago

unkownara commented 5 years ago

I got this error while importing s3 npm in React js project.

Error Message Module not found: Can't resolve 'module' in 'proj_path/node_modules/natives'

hellatan commented 5 years ago

this same issues is happening for node 10. For some reason, i'm seeing this as dependency output when i run yarn why graceful-fs:

=> Found "graceful-fs@4.1.11"
info Has been hoisted to "graceful-fs"
info Reasons this module exists
   - Hoisted from "enhanced-resolve#graceful-fs"
   - Hoisted from "chokidar#readdirp#graceful-fs"
   - Hoisted from "uglifyjs-webpack-plugin#cacache#graceful-fs"
// slew of other packages
info Disk size without dependencies: "28MB"
info Disk size with unique dependencies: "28MB"
info Disk size with transitive dependencies: "28MB"
info Number of shared dependencies: 0
=> Found "s3#graceful-fs@3.0.11"
info This module exists because "s3" depends on it.

I'm really not sure why s3 is still referencing graceful-fs@3.x in this case. I looked into <app-root>/node_modules/s3/node_modules and graceful-fs was there when it should have been resolved from <app-root>/node_modules/graceful-fs instead.

I just tried a fresh npm init and npm install s3 that points to the public registry (we use verdaccio at work so we have a private registry as well as use yarn instead of npm), and after creating the package-lock.json file, this is the output i get:

cat package-lock.json
{
  "name": "test-npm",
  "version": "1.0.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "aws-sdk": {
      "version": "2.0.31",
      "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.0.31.tgz",
      "integrity": "sha1-5yzx/caQFb2f0r3z07iMFlB9Jo4=",
      "requires": {
        "xml2js": "0.2.6",
        "xmlbuilder": "0.4.2"
      }
    },
    "fd-slicer": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz",
      "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=",
      "requires": {
        "pend": "~1.2.0"
      }
    },
    "findit2": {
      "version": "2.2.3",
      "resolved": "https://registry.npmjs.org/findit2/-/findit2-2.2.3.tgz",
      "integrity": "sha1-WKRmaX34piBc39vzlVNri9d3pfY="
    },
    "graceful-fs": {
      "version": "3.0.11",
      "resolved": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz",
      "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=",
      "requires": {
        "natives": "^1.1.0"
      }
    },
    "mime": {
      "version": "1.2.11",
      "resolved": "http://registry.npmjs.org/mime/-/mime-1.2.11.tgz",
      "integrity": "sha1-WCA+7Ybjpe8XrtK32evUfwpg3RA="
    },
    "minimist": {
      "version": "0.0.8",
      "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
      "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
    },
    "mkdirp": {
      "version": "0.5.1",
      "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
      "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
      "requires": {
        "minimist": "0.0.8"
      }
    },
    "natives": {
      "version": "1.1.6",
      "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz",
      "integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA=="
    },
    "pend": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
      "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA="
    },
    "rimraf": {
      "version": "2.2.8",
      "resolved": "http://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz",
      "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI="
    },
    "s3": {
      "version": "4.4.0",
      "resolved": "http://registry.npmjs.org/s3/-/s3-4.4.0.tgz",
      "integrity": "sha1-VqT3dVFae2ucjlxrGrUfkDdmnx8=",
      "requires": {
        "aws-sdk": "~2.0.31",
        "fd-slicer": "~1.0.0",
        "findit2": "~2.2.3",
        "graceful-fs": "~3.0.5",
        "mime": "~1.2.11",
        "mkdirp": "~0.5.0",
        "pend": "~1.2.0",
        "rimraf": "~2.2.8",
        "streamsink": "~1.2.0"
      }
    },
    "sax": {
      "version": "0.4.2",
      "resolved": "http://registry.npmjs.org/sax/-/sax-0.4.2.tgz",
      "integrity": "sha1-OfO2AXM9a+yXEFskKipA/Wl4rDw="
    },
    "streamsink": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/streamsink/-/streamsink-1.2.0.tgz",
      "integrity": "sha1-76/unx4i01ke1949yqlcP1559zw="
    },
    "xml2js": {
      "version": "0.2.6",
      "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.6.tgz",
      "integrity": "sha1-0gnE5N2h/JxFIUHvQcB39a399sQ=",
      "requires": {
        "sax": "0.4.2"
      }
    },
    "xmlbuilder": {
      "version": "0.4.2",
      "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-0.4.2.tgz",
      "integrity": "sha1-F3bWXz/brUcKCNhgTN6xxOVA/4M="
    }
  }
}

As you can see, s3 is still referencing graceful-fs@~3.0.5:

    "s3": {
      "version": "4.4.0",
      "resolved": "http://registry.npmjs.org/s3/-/s3-4.4.0.tgz",
      "integrity": "sha1-VqT3dVFae2ucjlxrGrUfkDdmnx8=",
      "requires": {
        "aws-sdk": "~2.0.31",
        "fd-slicer": "~1.0.0",
        "findit2": "~2.2.3",
        "graceful-fs": "~3.0.5",
        "mime": "~1.2.11",
        "mkdirp": "~0.5.0",
        "pend": "~1.2.0",
        "rimraf": "~2.2.8",
        "streamsink": "~1.2.0"
      }
    },

if you download the resolved tar file, uncompress it, then look at the package contents, the package.json file is listing "graceful-fs": "~3.0.5", as a dependency.

This is also the case if you download the latest 4.4.0 tag from this repo, I still see "graceful-fs": "~3.0.5", as a dependency. I checked 4.0.0, 4.2.0, 4.3.0, and 4.3.1 and all of them are still reference graceful-fs@3.x instead of graceful-fs@4.x.

It doesn't seem like this package has actually been published since February 15, 2015. The change to upgrade graceful-fs@4.x was made in 2016. It seems like there have a been a handful of changes since s3@4.4.0 was published that aren't in the public domain right now based on the commit history.

can someone please publish a new version of this package to get these fixes/updates into new npm version?

hellatan commented 5 years ago

if you're using yarn, an interim workaround is to use the "resolutions" field:

"resolutions": {
    "graceful-fs": "4.1.15"
}

and everything seems to work. It does not seem like npm has this support without adding another package.

hellatan commented 5 years ago

another solution, if you can, is to use the aws-sdk package instead - https://www.npmjs.com/package/aws-sdk. Depending on your current implementation, you'll have to do some minor changes.

bonesoul commented 5 years ago

same here..

bonesoul commented 5 years ago

i don't use yarn, is there any chances a new minor release with fixed graceful-fs version?