Coder Social home page Coder Social logo

jsr-npm's People

Contributors

azu avatar elrrrrrrr avatar marvinhagemeister avatar morinokami avatar nakasyou avatar redabacha avatar ry avatar ryoppippi avatar sebbo2002 avatar triyanox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jsr-npm's Issues

Error publishing package using node:readline/promises

No idea if this is where I should post the issue. I get an error when trying to publish my simple package to JSR:

$ npx jsr publish
Need to install the following packages:
[email protected]
Ok to proceed? (y) y

Downloading JSR binary...
[00:01] [#################################################>] 37.4 MiB/37.5 MiB
error: Unknown built-in "node:" module: readline/promises
    at file:///C:/Github/my-libraries/hvb-screenshots/dist/dist.js:9:22
Child process exited with: 1

Am I missing something?

Repro: https://github.com/henrikvilhelmberglund/hvb-screenshots

`jsr` errors on scopes that begin with a number

npx jsr add @2or3godzillas/fp-try  
Invalid jsr package name: A jsr package name must have the format @<scope>/<name>, but got "@2or3godzillas/fp-try"

node version: v20.12.2
npm version: 10.5.0
jsr version: 0.12.4

npx jsr add installs to the parent directory

I published a package as a test, then created a new test directory (all node.js based):

mkdir test-proj
cd test-proj
npm init -y

Then tried to install my project:

npx jsr add @spooky/dom-fns

Which added them to the parent directory's package.json and the parent directory's node_modules folder. I attempted to create an empty node_modules in the cwd but that did not change things.

tldr; I think jsr add has issues with empty projects.

Bug: After the second time `bunx jsr add ... ` is failed

I tried bunx jsr add .... The first time will be successful, but after that it will fail.

Reproduction procedure:

bun init
bunx jsr add @std/path
bunx jsr add @std/assert

Log for last command (bunx jsr add @std/assert):

Setting up bunfig.toml...ok
Installing @std/assert...
$ bun add @std/assert@npm:@jsr/std__assert
4 | "@jsr" = "https://npm.jsr.io/"
                                  ^
error: Cannot redefine key
    at /home/nakasyou1103/jsr-hello/bunfig.toml:4:31
SyntaxError: An error occurred while parsing code

I think reason is that it doesn't check if it've already written it when it writes [install.scopes] with jsr add.
I think you need a toml parser to fix it perfectly.

Reference code: https://github.com/jsr-io/jsr-npm/blob/main/src/commands.ts

add `jsr setup` subcommand for setting up `.npmrc` (, `bunfig.toml`, or `.yarnrc.yml` )

Currently jsr cli sets up these config files at the beginning of jsr install <pkg> subcommand, but it would be useful if jsr cli also provides a subcommand which only does that setup independently.

The use case of this is that when an npm package author use jsr package as its dependency, then they need to instruct its users to add .npmrc (or similar) settings to their projects. jsr setup command can be used for supporting that setup.


#63 might be related issue, but #11 implements a subcommand which generates an empty project with jsr set up.

findProjectDir: need to prioritize `bun.lockb` over `yarn.lock`

bun can save both "bun.lockb" and "yarn.lock".
It is said that this function is used to check the diff when updating the dependency.

Some users use this function to save both "bun.lockb" and "yarn.lock".

In the current implementation, prioritize yarn.lock over bun.lockd.
This will determine the package manager as a yarn even if you are using bun.

jsr-npm/src/utils.ts

Lines 76 to 130 in 37c8573

export async function findProjectDir(
cwd: string,
dir: string = cwd,
result: ProjectInfo = {
projectDir: cwd,
pkgManagerName: null,
pkgJsonPath: null,
},
): Promise<ProjectInfo> {
const npmLockfile = path.join(dir, "package-lock.json");
if (await fileExists(npmLockfile)) {
logDebug(`Detected npm from lockfile ${npmLockfile}`);
result.projectDir = dir;
result.pkgManagerName = "npm";
return result;
}
const yarnLockFile = path.join(dir, "yarn.lock");
if (await fileExists(yarnLockFile)) {
logDebug(`Detected yarn from lockfile ${yarnLockFile}`);
result.projectDir = dir;
result.pkgManagerName = "yarn";
return result;
}
const pnpmLockfile = path.join(dir, "pnpm-lock.yaml");
if (await fileExists(pnpmLockfile)) {
logDebug(`Detected pnpm from lockfile ${pnpmLockfile}`);
result.projectDir = dir;
result.pkgManagerName = "pnpm";
return result;
}
const bunLockfile = path.join(dir, "bun.lockb");
if (await fileExists(bunLockfile)) {
logDebug(`Detected bun from lockfile ${bunLockfile}`);
result.projectDir = dir;
result.pkgManagerName = "bun";
return result;
}
const pkgJsonPath = path.join(dir, "package.json");
if (await fileExists(pkgJsonPath)) {
logDebug(`Found package.json at ${pkgJsonPath}`);
result.projectDir = dir;
}
const prev = dir;
dir = path.dirname(dir);
if (dir === prev) {
return result;
}
return findProjectDir(cwd, dir, result);
}

Related

Add a search command

I think a search command will be something great to add to jsr
we can have:

  • If an argument is passed as the search query we return the relevant results if not we list all the packages to fill the limit.
  • A limit flag to limit the results shown
  • A skip flag to skip a specific amount of results
  • A registry flag maybe?
search-feature.mp4

I'm building this but I couldn't find any jsr api I can use any help with that ?

`jsr` CLI ignores global Bun config

What is the issue?

Currently if you run the recommended Bun command to add a dependency (bunx jsr add @std/log) & use a global Bun config (~/.bunfig.toml), such as myself where I already have other scopes / registries declared, it will not check to see if a global Bun config exists & as such it will both:

  • Fail to add / install the dependency
  • Repeatedly add an install scope to any existing bunfig.toml file

This seems to be because Bun will not even read a local / relative scope if a global config exists.

Steps to reproduce

  • echo '[install.scopes]\n' > ~/.bunfig.toml
  • bunx jsr add @std/log
➜ bunx jsr add @std/log
Setting up bunfig.toml...ok
Installing @std/log...
$ bun add @std/log@npm:@jsr/std__log
bun add v1.0.30 (1424a196)
  🔍 @jsr/std__log [1/1]
error: package "@jsr/std__log" not found registry.npmjs.org/@jsr%2fstd__log 404
error: @std/log@npm:@jsr/std__log failed to resolve

Possible solution

Currently it seems that JSR already checks the local / relative bunfig.toml file to see if a jsr scope exists & if not it adds it. This pre-script logic just needs to be extended to check if a global Bun config exists (~/.bunfig.toml) & if it does append the JSR scope to either that global config and/or a local config.

`.npmrc` needs to be craeted in the workspace root, not the current workspace

Issue

When using npm workspaces and trying to add JSR modules in one of the workspaces, it fails with NOT FOUND error.

Reproduction

Suppose the project structure looks like this, where npm workspaces is used:

.
├── package.json
└── workspace
    ├── index.mjs
    └── package.json

package.json

{
  "name": "simple_npm_workspace",
  "workspaces": ["workspace"]
}

workspace/package.json

{
  "name": "workspace",
  "main": "index.mjs"
}

Then let's say we want to import and use @std/async from JSR in the workspace, so run the following command:

$ cd workspace && npx jsr add @std/async

This errors out:

Setting up .npmrc...ok
Installing @std/async...
$ npm install @std/async@npm:@jsr/std__async
npm WARN ignoring workspace config at /private/tmp/simple_npm_workspace/workspace/.npmrc
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@jsr%2fstd__async - Not found
npm ERR! 404
npm ERR! 404  '@jsr/std__async@*' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: /Users/yusuktan/.npm/_logs/2024-04-14T02_01_33_513Z-debug-0.log
Child process exited with: 1

Possible solution

The error above was apparently because .npmrc is created in the workspace directory (i.e. workspace/.npmrc), but npm doesn't recognize it. If I move the created .npmrc to the workspace root directory and run the npx jsr add command again, it succeeds (duplicate .npmrc is created again in the workspace directory though).

$ mv workspace/.npmrc ./.npmrc
$ cd workspace && npx jsr add @std/async
Setting up .npmrc...ok
Installing @std/async...
$ npm install @std/async@npm:@jsr/std__async
npm WARN ignoring workspace config at /private/tmp/simple_npm_workspace/workspace/.npmrc

added 4 packages, and audited 6 packages in 1s

found 0 vulnerabilities

Completed in 1s

So one possible solution to this issue would be that when npx jsr add command is invoked it should traverse up the parent directories to check if the current working directory is a npm workspace or not. If it is, .npmrc needs to be created in the workspace root instead of the current working directory.

Publish the same package, `npx jsr publish` failed (JSR package manifest for 'xxxl' failed to load) but `deno publish` succeeded

The problem occurs in this simple example repository: https://github.com/eavidy/edv-test/tree/jsr-bug

deno.json

{
  "name": "@asla/vio",
  "version": "0.1.0",
  "exports": "./main.ts"
}

main.ts

import { createSocketCpc } from "jsr:@asn/[email protected]";
export { createSocketCpc };
console.log("ok!");

My workflow file

name: pull request
on:
  push:
jobs:
  case1:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: npx
        continue-on-error: true
        run: npx jsr publish --dry-run

      - name: Setup Deno
        uses: denoland/setup-deno@v1
      - name: deno
        run: deno publish --dry-run

  case2:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup Deno
        uses: denoland/setup-deno@v1
      - name: deno
        run: deno publish --dry-run

cacse1 and case2 both publish the same package, but case1 fails and case2 succeeds: https://github.com/eavidy/edv-test/actions/runs/9920143639
case1:
image
case2:
image

error: unexpected argument '--verbose' found

I can't figure out how to turn verbose debugging on:

$ npx jsr --version
0.12.2

$ npx jsr --help
...
            --verbose  Show additional debugging information.
...
$ npx jsr --verbose
node:internal/util/parse_args/parse_args:98
    throw new ERR_PARSE_ARGS_UNKNOWN_OPTION(
    ^

TypeError [ERR_PARSE_ARGS_UNKNOWN_OPTION]: Unknown option '--verbose'. To specify a positional argument starting with a '-', place it at the end of the command after '--', as in '-- "--verbose"
$ npx jsr publish --verbose
error: unexpected argument '--verbose' found

Usage: deno publish --unstable-bare-node-builtins --unstable-sloppy-imports --unstable-byonm --no-check[=<NO_CHECK_TYPE>]

For more information, try '--help'.

Child process exited with: 1

jsr upgrade

I haven't found a way to upgrade a package in a Node.js project besides jsr remove <pkg> then jsr add <pkg>

"Cannot find module '(...)\node_modules\jsr\dist\bin.js'"

I've installed JSR to my project using npm install --save-dev jsr, which worked fine, and I could then run npx jsr --help to get the JSR help menu:

PS C:\Users\Administrator\Documents\Programming\Projects\Public\dexonline-scraper> npm install --save-dev jsr

added 3 packages, and audited 121 packages in 2s

34 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
PS C:\Users\Administrator\Documents\Programming\Projects\Public\dexonline-scraper> npx jsr --help
jsr.io cli for node

Usage:
     jsr add @std/log  Install the "@std/log" package from jsr.io.
  jsr remove @std/log  Remove the "@std/log" package from the project.

Commands:
       i, install, add  Install one or more JSR packages.
  r, uninstall, remove  Remove one or more JSR packages.
               publish  Publish a package to the JSR registry.

Options:
      -P, --save-prod  Package will be added to dependencies. This is the default.
       -D, --save-dev  Package will be added to devDependencies.
  -O, --save-optional  Package will be added to optionalDependencies.
                --npm  Use npm to remove and install packages.
               --yarn  Use yarn to remove and install packages.
               --pnpm  Use pnpm to remove and install packages.
                --bun  Use bun to remove and install packages.
            --verbose  Show additional debugging information.
           -h, --help  Show this help text.
        -v, --version  Print the version number.

Publish Options:
     --token <Token>  The API token to use when publishing. If unset, interactive authentication will be used.
           --dry-run  Prepare the package for publishing performing all checks and validations without uploading.
  --allow-slow-types  Allow publishing with slow types.
        --provenance  From CI/CD system, publicly links the package to where it was built and published from.

Environment variables:
        JSR_URL  Use a different registry URL for the publish command.
  DENO_BIN_PATH  Use specified Deno binary instead of local downloaded one.

However, upon running npx jsr publish, I get the following error:

PS C:\Users\Administrator\Documents\Programming\Projects\Public\dexonline-scraper> npx jsr publish   
Downloading JSR binary...
[00:01] [#################################################>] 35.3 MiB/35.5 MiB
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/index.ts:2:19
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/index.ts:3:86
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/index.ts:4:29
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/index.ts:5:28
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/inflection.ts:2:25
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/inflection.ts:3:23
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/inflection.ts:4:52
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/synthesis.ts:2:25 
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/synthesis.ts:3:23 
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/synthesis.ts:4:67 
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/synthesis.ts:5:21 
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/synthesis.ts:6:22
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/constants/selectors.ts:1:29
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/synthesis/row.ts:2:37
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/synthesis/row.ts:3:23
Warning Sloppy module resolution (hint: update .js extension to .ts)
    at file:///C:/Users/Administrator/Documents/Programming/Projects/Public/dexonline-scraper/src/tabs/synthesis/row.ts:4:31
error: Failed creating junction and fallback symlink in node_modules folder.

Cannot create a file when that file already exists. (os error 183)

Cannot create a file when that file already exists. (os error 183), symlink 'C:\Users\Administrator\Documents\Programming\Projects\Public\dexonline-scraper\node_modules\.deno\[email protected]\node_modules\jsr' -> 'C:\Users\Administrator\Documents\Programming\Projects\Public\dexonline-scraper\node_modules\jsr'

After which, npx jsr becomes unavailable:

PS C:\Users\Administrator\Documents\Programming\Projects\Public\dexonline-scraper> npx jsr
node:internal/modules/cjs/loader:1051
  throw err;
  ^

Error: Cannot find module 'C:\Users\Administrator\Documents\Programming\Projects\Public\dexonline-scraper\node_modules\jsr\dist\bin.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.6.1

Installing jsr as a global package works just fine, however.

Installation information

NPM version: 10.1.0
Node.js version: 20.6.1
Operating system: Windows 10
Package/repository: https://github.com/vxern/dexonline-scraper

Use `.npmrc` for Bun

In Bun v1.1.18, .npmrc file is supported
https://bun.sh/blog/bun-v1.1.18#npmrc-support

In current implementation, Bun's jsr installing experience is not good.
We cannot specify package version... which we can use with npm/pnpm.
And that caused some errors when uploading to JSR if the jsr package was included as a dependency in the Bun project.

So, when we switch to use .npmrc, we can specify version

Add init command

It would be great to have an init command for CI and in general to set the @jsr:registry=https://npm.jsr.io line in the .npmrc file without having to add a package.

I would suggest providing a global option if one wants to update the users config file, otherwise adds it in the local project.

I am happy to provide a PR for this.

Spelling mistake in project description

Something small but noticed and thought I should point it out, but in the current project description it says:
A cli tool to make installing packages form jsr.io in node easy

from is misspelled as form

should be

A cli tool to make installing packages from jsr.io in node easy

¯_(ツ)_/¯

Bug: pnpm registry mismatch error

From https://medium.com/frontendweb/step-by-step-guidelines-on-how-to-publish-a-deno-package-to-the-jsr-registry-d253139d2329

If you're running, jsr add command in your nextjs or existing project with pnpm to install the jsr registry package.

pnpm dlx jsr add @officialrajdeepsingh/slugify

You face this type of error.

➜  next-testing-app git:(main) pnpm dlx jsr add @officialrajdeepsingh/slugify

Packages: +3
+++
Progress: resolved 3, reused 3, downloaded 0, added 3, done
Setting up .npmrc...ok
Installing @officialrajdeepsingh/slugify...
$ pnpm add @officialrajdeepsingh/slugify@npm:@jsr/officialrajdeepsingh__slugify
 ERR_PNPM_REGISTRIES_MISMATCH  This modules directory was created using the following registries configuration: {"default":"https://registry.npmjs.org/"}. The current configuration is {"default":"https://registry.npmjs.org/","@jsr":"https://npm.jsr.io/"}. To recreate the modules directory using the new settings, run "pnpm install".

JSR Command fails on Windows

OS: Windows
Package Manager: pnpm

I tried to run jsr using npm dlx jsr publish but I got this

 npx jsr publish --dry-run
Need to install the following packages:
[email protected]
Ok to proceed? (y) Y

Downloading JSR binary...
[00:00] [#################################################>] 37.2 MiB/37.6 MiB
'C:\Users\Venel' is not recognized as an internal or external command,
operable program or batch file.
Child process exited with: 1

It has something to do with windows path but I don't know if I can fix this I might have to install jsr instead.
Link to minimal reproducible example: https://github.com/louiss0/dummy-jsr

Allow 3-word install with npm, pnpm, yarn, bun (w. fallback to npm registry)

Problem

If I take @mxdvl/valibot as an example, the commands are varied in DX:

Deno: nice, 3 words, just like using npm registry packages with npm/Yarn/pnpm

deno add @mxdvl/valibot

All other package managers: verbose and hard to remember:

# 4 words
npx jsr add @mxdvl/valibot
bunx jsr add @mxdvl/valibot

# 5 words
pnpm dlx jsr add @mxdvl/valibot
yarn dlx jsr add @mxdvl/valibot

Proposal

Contribute / propose features to all common package managers npm, pnpm, yarn, bun to allow for simple 3-word commands with better DX:

# 3 words
npm add @mxdvl/valibot
pnpm add @mxdvl/valibot
bun add @mxdvl/valibot
yarn add @mxdvl/valibot

Fallback to npm feature: If the package is not found in jsr.io's registry, then the npm registry will be searched, using the rules that jsr currently uses

This may require some sort of:

  1. multiple registry support
  2. prioritization of registry order (eg. jsr first, then npm)
  3. option to exclude a registry (eg. jsr first, npm never)

...or maybe package managers already have both these features? If so, maybe that should be suggested as the first way to install the package instead of the npx, bunx, dlx commands above...? 🤔

Alternatives considered

Add a small global jsr binary that will add/update/remove the package with your current package manager, similar to Corepack

jsr add @mxdvl/valibot

Relevant discussion is happening recently about Corepack's "packageManager" field:

  1. Enable Corepack by default (issue) nodejs/node#50963
  2. Enable Corepack yarn and pnpm by default (PR) nodejs/node#51886
  3. "packageManager" doesn't support npm nodejs/node#51888
  4. "packagemanager" field is too limited nodejs/corepack#402
  5. Define spec for development environment field openjs-foundation/package-metadata-interoperability-collab-space#15

Installation fails with existing .npmrc

I added jsr to an existing project that already had a .npmrc file with a few entries. When executing npm i jsr -D the line @jsr:registry=https://npm.jsr.io was appended to the last line in the file instead of being put on a new line. This causes npx jsr add ... to fail.

CommonJS

Why is the tool for the ECMAScript module only registry outputting CommonJS?

I would expect it to be in ESM too, ignoring the legacy CommonJS like its registry does. When the (Node.js) runtime does not support esm in the first place JSR as a whole is useless anyway. Publishing the code is not of interest and installing from JSR wont work either.

"module": "CommonJS",

Package installation error caused by parent directory package.json

The problem

When running npx jsr add @cross/env in a directory without a package.json file, and a package.json file exists in a parent directory, you do receive an error message like this:

➜  examples git:(main) ✗ npx jsr add @cross/env   
Installing @cross/env...
$ npm install @cross/env@npm:@jsr/cross__env
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@jsr%2fcross__env - Not found
npm ERR! 404 
npm ERR! 404  '@jsr/cross__env@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: /home/<user>/.npm/_logs/2024-03-10T23_19_06_360Z-debug-0.log

The same goes for bunx jsr

Steps to reproduce

  1. Create /home/user/package.json

  2. Create a new folder /home/user/git/repo/ and cd to it

  3. Run npx jsr add @cross/env

Actual result

Above error message, saying that the package was not found

Expected result

Ideally, JSR should either:

  • Recognize that the current directory is a separate workspace, create package.json, and install the package.

  • Provide a more informative error message explaining that the identified workspace is not configured for jsr, and suggest solutions.

Workround

Create a valid package.json file in the directory where you want to install the package. This will override the parent directory's package.json and ensure that everything goes as planned.

In `jsr publish`, only apply compat fixes (`--unstable-sloppy-imports`, etc) when project has `package.json`

Right now the default behaviour of jsr publish and deno publish in projects without package.json is different. For these (deno) projects, the behaviour should be identical.

We should not enable any of these options unless a package.json is found in the repository:

jsr-npm/src/commands.ts

Lines 159 to 162 in 25124b8

"--unstable-bare-node-builtins",
"--unstable-sloppy-imports",
"--unstable-byonm",
"--no-check",

Because of this discrepancy, users have run into issues: https://discord.com/channels/684898665143206084/1216305070258524181

`yarn dlx jsr add` does not work when following Yarn 2 & jsr basic setup docs

I created an empty project with Yarn, following Yarn's docs in an empty folder:

corepack enable
yarn init -2

Then, I run yarn dlx jsr add @nic-test/test-log (copy-pasted from the Yarn tab at https://jsr.io/@nic-test/[email protected]), and I get this output:

➜ yarn dlx jsr add @nic-test/test-log
➤ YN0000: · Yarn 4.1.0
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + jsr@npm:0.9.0, kolorist@npm:1.8.0, node-stream-zip@npm:1.15.0
➤ YN0000: └ Completed in 0s 567ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 3 packages were added to the project (+ 167.89 KiB).
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done in 0s 628ms

Setting up .npmrc...ok
Installing @nic-test/test-log...
$ yarn add @nic-test/test-log@npm:@jsr/nic-test__test-log
➤ YN0000: · Yarn 4.1.0
➤ YN0000: ┌ Resolution step
➤ YN0001: │ Error: @nic-test/test-log@npm:@jsr/nic-test__test-log isn't supported by any available resolver
    at Dd.getResolverByDescriptor (/Users/nic/.cache/node/corepack/yarn/4.1.0/yarn.js:141:1698)
    at Dd.bindDescriptor (/Users/nic/.cache/node/corepack/yarn/4.1.0/yarn.js:141:1083)
    at Pt.preparePackage (/Users/nic/.cache/node/corepack/yarn/4.1.0/yarn.js:210:6173)
    at async ne (/Users/nic/.cache/node/corepack/yarn/4.1.0/yarn.js:210:7583)
    at async Promise.allSettled (index 0)
    at async Uc (/Users/nic/.cache/node/corepack/yarn/4.1.0/yarn.js:140:53244)
    at async /Users/nic/.cache/node/corepack/yarn/4.1.0/yarn.js:210:9140
    at async Nt.startProgressPromise (/Users/nic/.cache/node/corepack/yarn/4.1.0/yarn.js:140:137284)
    at async Pt.resolveEverything (/Users/nic/.cache/node/corepack/yarn/4.1.0/yarn.js:210:7138)
    at async /Users/nic/.cache/node/corepack/yarn/4.1.0/yarn.js:213:2648
➤ YN0000: └ Completed
➤ YN0000: · Failed with errors in 0s 13ms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.