adobe / leonardo

Generate colors based on a desired contrast ratio
http://www.leonardocolor.io
Apache License 2.0
1.97k stars 108 forks source link

Module not found: Error: Can't resolve '@adobe/leonardo-contrast-colors' #173

Open skylerknight opened 2 years ago

skylerknight commented 2 years ago

Description

Unable to use package. Keep getting "Module not found" or "No exported member" errors.

I have tried both npm and yarn, with CRA and vite.

Steps to reproduce

  1. Initiate a basic application: npx create-react-app learn-leo

  2. Install package npm i @adobe/leonardo-contrast-colors

  3. Import Leonardo Package:

    
    // App.js

import * as Leo from "@adobe/leonardo-contrast-colors"


4. Run application:`npm start`

5. Resulting error:

```shell
Failed to compile.

Module not found: Error: Can't resolve '@adobe/leonardo-contrast-colors' in '/Users/username/Development/learn-leo/src'
ERROR in ./src/App.js 6:0-50
Module not found: Error: Can't resolve '@adobe/leonardo-contrast-colors' in '/Users/username/Development/learn-leo/src'

webpack compiled with 1 error

Expected behavior

Expected to be able to import and use the leonardo package.

Screenshots

Screen Shot 2022-08-21 at 2 12 20 PM

Leonardo package and version

@leonardo-contrast-colors version: ^1.0.0-alpha.16

Environment

Additional context

It appears that there may be something wrong with the exposed modules/files for export.

The package may have incorrect main/module/exports specified in its package.json.

UPDATE: I've tested with Version 1.0.0-alpha.13 and I am no longer seeing this error. It must have something to do with the latest release.

elyulka commented 2 years ago

@skylerknight package.json contains incorrect "main" and "export" fields. Next changes fix the issue:

"main": "./dist/index.js",
"exports": {
    ".": {
      "default": "./dist/index.js"
    }
  },

Upd: Nope, gives ReferenceError: exports is not defined in ES module scope

There is type: "module" and index.mjs present but it's not usable at least because of required utils.mjs uses apca-w3 that isn't present in dependencies but indevDependencies.

@NateBaldwinDesign It became broken after PR #166 had been merged

skylerknight commented 2 years ago

@elyulka Aha,thanks for the info

pabloromeroelux commented 2 years ago

what's the best way around so far? Backing to 1.0.0-alpha.13 gives me this #175. I might be missing something about how to use the package

xaddict commented 1 year ago

Problem is still there

https://stackblitz.com/edit/vitejs-vite-eaduzs?file=main.js