adding node packages
Are there any special considerations when adding node packages to the dummy app starter template? Do I just wrong the npm install cli command and I’m good or is there more that I need to do? Asking before I make a mess lol.
3 Replies
Hi @JLegendz. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In a Wasp project, you can add new dependencies in a standard way for JavaScript projects: using the
package.json
file, located at the root of your project. You can list your dependencies under the dependencies
or devDependencies
fields. To add a new package, you can use the npm install
command. For example, to add a package like date-fns
, you would run:
This command will add the package in the dependencies
section of your package.json
file.
However, there are some considerations to keep in mind. Wasp uses some packages internally, like react
and wasp
, and you should not modify or remove these. Also, if Wasp is already using a certain dependency with a certain version specified, you are not allowed to define that same npm dependency yourself while specifying a different version. If you do that, you will get an error message telling you which exact version you have to use for that dependency. This means Wasp dictates exact versions of certain packages, so for example, you can't choose the version of React you want to use.
There is an open issue on the Wasp GitHub to allow adding NPM dependencies from the CLI, which would behave like npm install foo
and add the latest version to your .wasp file. However, this feature is not yet implemented.
For more information, you can refer to the Wasp documentation on dependencies (https://wasp-lang.dev/docs/project/dependencies).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @JLegendz, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Yeah you can just do
npm install
!Here are the docs on it: https://wasp-lang.dev/docs/project/dependencies
Dependencies | Wasp
In a Wasp project, dependencies are defined in a standard way for JavaScript projects: using the package.json file, located at the root of your project. You can list your dependencies under the dependencies or devDependencies fields.