npm

package module
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: MIT Imports: 17 Imported by: 1

README

NPM

Go Reference

Simple NPM client for installing node_modules.

Features

  • Makes direct HTTPS calls to the NPM registry
  • You don't need NPM installed
  • Less logging

Install

go get github.com/livebud/npm

Example

Install specific packages:

npm.Install(ctx, dir, "react@18.2.0", "react-dom@18.2.0")

Install from a package.json in dir:

{
  "dependencies": {
    "preact": "10.19.4",
    "preact-render-to-string": "6.3.1",
    "@lukeed/uuid": "^2.0.1"
  }
}
npm.Install(ctx, dir)

Contributors

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install(ctx context.Context, dir string, packages ...string) error

func Version added in v0.0.7

func Version(ctx context.Context, pkgname, constraint string) (string, error)

Version resolves the version of a package. To get the latest you can do `version, err := npm.Version(ctx, "preact", "*")`.

Types

type Manifest added in v0.0.6

type Manifest struct {
	Name    string                       `json:"name,omitempty"`
	Main    string                       `json:"main,omitempty"`
	Browser string                       `json:"browser,omitempty"`
	Files   []string                     `json:"files,omitempty"`
	Imports map[string]map[string]string `json:"imports,omitempty"`
	// TODO: this can also be a string or list
	Exports      map[string]string `json:"exports,omitempty"`
	Dependencies map[string]string `json:"dependencies,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL