jspm / generator

JSPM Import Map Generator
Apache License 2.0
160 stars 20 forks source link

when install from node_modules, "name"/"dependencies" in package.json should not be used #311

Open GongT opened 11 months ago

GongT commented 11 months ago

reproduce steps:

  1. install in a empty dir: corepack npm install --save react@npm:preact jspm
  2. run jspm: jspm "install" "--provider" "nodemodules" "react"

result:

Error: file:///tmp/qqq/node_modules/preact does not exist, try installing "preact" with npm first via "npm install preact".

source:

https://github.com/jspm/generator/blob/11475a5f47e18a72b38f1860c110dd7fe4d12ef4/src/install/package.ts#L219C13-L219C13

detail:

The new jspm do not download anything to local filesystem, version (or url) of a package doesn't seem to make sense.

I also see some code (many come from 2 years ago) is reading "name" field in package.json, I think they are "happens to be ok".

guybedford commented 11 months ago

This is because JSPM generator does not respect the "react" alias when doing an install from the nodemodules provider.

If you instead fo jspm install --provider nodemodules react=preact it will work correctly in this case I believe.