status-web icon indicating copy to clipboard operation
status-web copied to clipboard

Failed to require/import @status-im/js in Node.js

Open yqrashawn opened this issue 2 years ago • 2 comments

Got Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/yqrashawn/Downloads/test/node_modules/js-waku/package.json error CleanShot 2023-05-05 at 15 47 11

yqrashawn avatar May 05 '23 07:05 yqrashawn

When require("@status-im/js")

Node.js complains about js-waku/package.json, because there are only types and import, no require

    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js"
    },

When import statusjs from "@status-im/js"

Node.js import the @status-im/js/dist/index.cjs not @status-im/js/dist/index.js

When import statusjs from "@status-im/js/dist/index.js"; instead of cjs

Node.js complains about can't find ethereum-cryptography/utils because it's not ethereum-cryptography/utils.js and there's no exports in node_modules/ethereum-cryptography/package.json

yqrashawn avatar May 08 '23 08:05 yqrashawn

A bit background

I'm currently working on ISSUE3 in this issue https://github.com/status-im/status-mobile/issues/15500#issuecomment-1485455153 which requires updating https://github.com/status-im/universal-links-handler to fetch user display name from waku

yqrashawn avatar May 08 '23 08:05 yqrashawn