Jump to content

Node.js: Difference between revisions

994 bytes added ,  3 April 2023
add example of a nix flake for developer shell.
imported>Milahu
m (typo: wiki -> manual)
imported>Garethstokes
(add example of a nix flake for developer shell.)
Line 182: Line 182:
     export PATH="${NPM_CONFIG_PREFIX}/bin:$PATH"
     export PATH="${NPM_CONFIG_PREFIX}/bin:$PATH"
   '';
   '';
}
</syntaxhighlight>
== Example nix flake shell for Node.js development ==
`flake.nix` example:
<syntaxhighlight lang="nix>
{
  description = "example-node-js-flake";
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
  };
  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
      let
        pkgs = import nixpkgs {
          inherit system;
        };
        buildNodeJs = pkgs.callPackage "${nixpkgs}/pkgs/development/web/nodejs/nodejs.nix" {
          python = pkgs.python3;
        };
        nodejs = buildNodeJs {
          enableNpm = true;
          version = "16.16.0";
          sha256 = "FFFR7/Oyql6+czhACcUicag3QK5oepPJjGKM19UnNus=";
        };
      in rec {
        flakedPkgs = pkgs;
        # enables use of `nix shell`
        devShell = pkgs.mkShell {
          # add things you want in your shell here
          buildInputs = with pkgs; [
            nodejs
          ];
        };
      }
    );
}
}


Anonymous user