framework icon indicating copy to clipboard operation
framework copied to clipboard

Support alternative npm registries

Open EE2dev opened this issue 1 year ago • 5 comments

I am unable to setup observable framework at my workplace:

  • windows 10
  • node v20.18.0

To reroute npm installs to our internal registry, registry and other setting are placed in a .npmrc file in the home directory

  1. npx "@observablehq/framework@latest" create
  2. cd hello-framework
  3. npm run dev --> leads to an error:
GET /
npm:@observablehq/plot@latest → TypeError: fetch failed
    at node:internal/deps/undici/undici:13185:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async <myPath>/node_modules/@observablehq/framework/dist/npm.js:207:22{
  [cause]: Error: getaddrinfo ENOTFOUND [registry.npmjs.org](http://registry.npmjs.org/)

The only way I was able to fix it was to change line 200 in ./node_modules/@observablehq/framework/dist/npm.js const href =https://registry.npmjs.org/${name}${disttag ? /${disttag} : ""}; with the URL of our registry.

Question 1: That doesn't seem to right way to set up observable, changing this file ?!

  1. As a result npm run dev (after modifying npm.js) leads to:
GET /
npm:@observablehq/plot@latest → TypeError: fetch failed
   at node:internal/deps/undici/undici:13185:13
   at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
   at async <mypath>/node_modules/@observablehq/framework/dist/npm.js:201:22 {
 [cause]: Error: self-signed certificate in certificate chain
     at TLSSocket.onConnectSecure (node:_tls_wrap:1677:34)
     at TLSSocket.emit (node:events:519:28)
     at TLSSocket._finishInit (node:_tls_wrap:1076:8)
     at ssl.onhandshakedone (node:_tls_wrap:862:12) {
   code: 'SELF_SIGNED_CERT_IN_CHAIN'
  }
}

Question 2: how can I fix this to proceed setting up framework?

I found

  • https://github.com/observablehq/framework/discussions/1480
  • https://github.com/observablehq/framework/discussions/1481 but didnt see any help there.

EE2dev avatar Nov 13 '24 23:11 EE2dev

We don’t support alternative npm registries at the moment, but that’s a feature we could add. Currently Framework requires access to registry.npmjs.org and cdn.jsdelivr.net in order to install libraries from npm.

(This feels related to support for HTTP_PROXY, which you can implement in your config as described in https://github.com/observablehq/framework/issues/1168#issuecomment-2028238020.)

mbostock avatar Nov 13 '24 23:11 mbostock

Can I upvote the alternative npm registries option somewhere?

Do you think the second question is also solved when alternative registries are supported?

EE2dev avatar Nov 13 '24 23:11 EE2dev

You can add a 👍 reaction to this issue that you filed, but that’s implied by you filing this issue in the first place. 😅 This isn’t the same as the HTTP_PROXY issue, and solving one doesn’t solve the other, but they are both related to supporting Framework on restricted networks and hence worth cross-linking.

mbostock avatar Nov 14 '24 05:11 mbostock

the same folks who want to upvote this are probably on managed github enterprise accounts and unable to contribute to repositories outside of their enterprise (like me😂, had to use my personal account). big fan of the framework Mike, thank you, but adoption is hindered by inability to include our internal enterprise npm packages from jfrog artifactory.

bskinnersf avatar Dec 11 '24 14:12 bskinnersf

Just wanted to add +1 to original issue and to @bskinnersf's comment. This is an awesome framework. I tried it for my personal projects. Would love to be able to use it within an enterprise context too.

cherihung avatar Dec 16 '24 01:12 cherihung