{"id":21382973,"url":"https://github.com/josecfreittas/npm_deps","last_synced_at":"2025-07-13T13:31:47.629Z","repository":{"id":61396174,"uuid":"551246381","full_name":"josecfreittas/npm_deps","owner":"josecfreittas","description":"Manage NPM dependencies in your Elixir projects, without Node or NPM.","archived":false,"fork":false,"pushed_at":"2024-03-01T14:58:53.000Z","size":40,"stargazers_count":11,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-08T18:17:28.183Z","etag":null,"topics":["elixir","hex","liveview","npm","phoenix"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/josecfreittas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-10-14T04:09:29.000Z","updated_at":"2024-02-11T02:32:33.000Z","dependencies_parsed_at":"2024-02-11T02:42:26.053Z","dependency_job_id":null,"html_url":"https://github.com/josecfreittas/npm_deps","commit_stats":{"total_commits":15,"total_committers":3,"mean_commits":5.0,"dds":0.1333333333333333,"last_synced_commit":"0ad81fc2b94c7ce30f593cdc2fe6e993c31147da"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josecfreittas%2Fnpm_deps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josecfreittas%2Fnpm_deps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josecfreittas%2Fnpm_deps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josecfreittas%2Fnpm_deps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/josecfreittas","download_url":"https://codeload.github.com/josecfreittas/npm_deps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225885446,"owners_count":17539641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","hex","liveview","npm","phoenix"],"created_at":"2024-11-22T11:04:29.410Z","updated_at":"2024-11-22T11:04:29.866Z","avatar_url":"https://github.com/josecfreittas.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Hex.pm Version](https://img.shields.io/hexpm/v/npm_deps.svg?color=blueviolet)](https://hex.pm/packages/npm_deps)\n[![Hex docs](https://img.shields.io/badge/hex.pm-docs-blue.svg?style=flat)](https://hexdocs.pm/npm_deps)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE)\n\n\n# NpmDeps\n\n\u003c!-- MDOC !--\u003e\n\n### A tool to help you manage your NPM dependencies in Elixir projects without the need of Node.js or NPM in your environment.\n\n\n## Setup\n\nThe package can be installed by adding `npm_deps` to your list of dependencies in `mix.exs`. And you should also add the `npm_deps` to your `project/0`, pointing to a list with your desired NPM dependencies.\n\n```diff\n  def project do\n    [\n      app: :your_app,\n      version: \"0.1.0\",\n      elixir: \"~\u003e 1.14\",\n      ...\n+     npm_deps: npm_deps()\n    ]\n  end\n\n  def deps do\n    [\n      ...\n+     {:npm_deps, \"~\u003e 0.3.3\", runtime: false}\n    ]\n  end\n\n+ def npm_deps do\n+   [\n+     {:alpinejs, \"3.11.1\"},\n+     {:topbar, \"2.0.1\"},\n+     {\"decimal.js\", \"10.4.3\"}\n+   ]\n+ end\n```\n\n\u003e ℹ️ Alpine.js, Topbar and decimal.js are used in the example above, but you can use any NPM package you want.\n\n\u003e ℹ️ NpmDeps will not fetch the sub-dependencies of the packages, so you will need to add them explicitly to your `npm_deps/0` function if you need them.\n\n\u003e ℹ️ Post-install scripts are not supported.\n\nOnce you have added it, you can run `mix npm_deps.get` to get your NPM dependencies.  \n\nThe NPM dependencies will be installed in the `deps/` directory of your project, side by side with the Elixir dependencies.  \n\nIf you are using Phoenix and ESBuild, the default setup will work out of the box. Allowing you to import the NPM dependencies in your JS files.\n\n```javascript\nimport \"phoenix_html\";\nimport { Socket } from \"phoenix\";\nimport { LiveSocket } from \"phoenix_live_view\";\nimport topbar from \"topbar\";\nimport Alpine from \"alpinejs\";\n\nwindow.Alpine = Alpine;\nAlpine.start();\n\n...\n```\n\nTo run `npm_deps.get` in your deployment pipeline, you can add it to your `assets.deploy` task, also in `mix.exs`.\n\n```diff\n  defp aliases do\n    [\n      ...\n      \"assets.deploy\": [\n+       \"npm_deps.get\",\n        \"esbuild default --minify\",\n        \"phx.digest\"\n      ]\n    ]\n  end\n```\n\n\n\u003c!-- MDOC !--\u003e\n\n## Acknowledgements\nThe base of this package is based on the [dart_sass](https://github.com/CargoSense/dart_sass) and [esbuild](https://github.com/phoenixframework/esbuild) packages.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosecfreittas%2Fnpm_deps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosecfreittas%2Fnpm_deps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosecfreittas%2Fnpm_deps/lists"}