optimal-select icon indicating copy to clipboard operation
optimal-select copied to clipboard

Snowpack can't find `node_modules/optimal-select/src/index.js`

Open ziodave opened this issue 4 years ago • 2 comments

Hello,

I am using Snowpack, my package.json looks something like this:

{
  "name": "app",
  "version": "0.0.1",
  "description": "",
  "main": "src/index.js",
  "scripts": {
    "start": "snowpack dev",
    "build": "snowpack build",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "esbuild": "^0.12.5",
    "snowpack": "^3.5.2",
    "tslib": "^2.2.0",
    "typescript": "^4.3.2"
  },
  "dependencies": {
    "optimal-select": "^4.0.1"
  }
}

When I try to npm start I get the following error:

[snowpack] We resolved "optimal-select" to ./node_modules/optimal-select/src/index.js, but the file does not exist on disk.

In node_modules/optimal-select I can't find the src folder:

image

By looking into the package.json file I can see the following declaration:

…
"module": "src/index.js",
…

If I change it to

…
"module": "lib/index.js",
…

it works.

Is it the right thing to do?

ziodave avatar Jun 24 '21 11:06 ziodave

Yes we’re doing this in order to get it to bundle correctly. You can use patch-package to generate a patch and apply it before your build.

We changed the module line to dist/index.js.

Alternatively use one of the pre-bundled files from the dist folder in this repo.

cjroebuck avatar Jan 21 '25 09:01 cjroebuck

您好,我最近比较忙,无法亲自回复您的邮件。我如果我看到您的邮件,我会尽快给您回复。

xiemms avatar Jan 21 '25 09:01 xiemms