Testing NPM Packages Locally

In tandem with my Wasp app, I'm developing a library of 3D components for visualizing robots. Also, I need to test my own fixes to the Viam robotics framework TypeScript API. What is the best way to test local npm packages using Wasp? BTW, here is the excellent Medium article I found on the subject, but uses the npm CLI: https://medium.com/@oresoftware/node-js-how-to-test-your-new-npm-module-without-publishing-it-every-5-minutes-3b6f8e0491dd
Medium
Node.js — How to test your new NPM module without publishing it eve...
Because every module I used/installed came from the NPM registry, I had never loaded a local NPM module before, even though I had even…
4 Replies
miho
miho15mo ago
You can specify the package version as a path to the local folder. Something like this:
app depsTest {
wasp: {
version: "^0.11.5"
},
title: "deps-test",
dependencies: [
("some-local-package", "file:/tmp/deps-test/packages/some-local-package")
]
}

route RootRoute { path: "/", to: MainPage }
page MainPage {
component: import Main from "@client/MainPage.jsx"
}
app depsTest {
wasp: {
version: "^0.11.5"
},
title: "deps-test",
dependencies: [
("some-local-package", "file:/tmp/deps-test/packages/some-local-package")
]
}

route RootRoute { path: "/", to: MainPage }
page MainPage {
component: import Main from "@client/MainPage.jsx"
}
Where some-local-package is the folder of the package containing the package.json file Where the /tmp/deps-test/packages/some-local-package is the absolute path to the folder on your machine
Chris Paliqaw
Chris PaliqawOP15mo ago
very cool!
ranma
ranma14mo ago
is it possible to include npm module from a repository ? in npm, this is possible by using
npm install git+https://github.com/username/myrepo.git#version
npm install git+https://github.com/username/myrepo.git#version
miho
miho14mo ago
Hey, sorry for the late response, but since Wasp maps it's deps config to package.json directly you can install packages via Git as well. For example npm install git+https://github.com/organisation/repo.git#tag results with this line in package.json usually:
"repo": "github:organisation/repo#tag"
"repo": "github:organisation/repo#tag"
This means you can add the same thing in Wasp by adding this to dependencies array:
("repo", "github:organisation/repo#tag")
("repo", "github:organisation/repo#tag")
Want results from more Discord servers?
Add your server