When does wasp decide to do npm install during development?
It seems to be random when I run db migrate-dev and takes a really long time
3 Replies
Hi @Landyn. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Wasp decides to run npm install during development when it detects that dependencies may have changed or are missing. This typically happens in the following scenarios:
- When you run commands like wasp start or wasp db migrate-dev, Wasp checks if the necessary node_modules are present and if the dependencies have changed since the last install. If dependencies have changed, or if node_modules is missing, it will trigger npm install before proceeding. This is to ensure that all required packages are available for the generated code to work properly. If npm install fails or is interrupted, Wasp will attempt it again the next time you run a command that requires dependencies to be installed. This can make it seem "random" if you are not aware of what triggered the dependency change or removal. The process can take a long time, especially on the first run or on machines with slow internet or limited resources, and there is currently limited progress output during npm install, which can make it feel like nothing is happening for a while Get npm install during wasp start to output more details When dependency is added, warn user to restart wasp start or have wasp start run npm install automatically.
- Wasp tries to avoid unnecessary npm installs by tracking the set of dependencies used during the last install. If the dependencies haven't changed, it skips npm install. However, if there is no record of a successful install, or if dependencies have changed (for example, after editing your Wasp file or adding a new dependency), npm install will run again When dependency is added, warn user to restart wasp start or have wasp start run npm install automatically.
- For db commands like wasp db migrate-dev, Wasp will also ensure that code generation and npm install have been completed before running the migration, to avoid issues with missing dependencies or tools like Prisma Db commands (migrate) can be executed before Prisma CLI was installed.
If you notice npm install running frequently or taking a long time, it may be due to changes in dependencies, missing node_modules, or running commands in a clean environment. There are ongoing discussions in the Wasp community about improving the detection of when npm install is necessary and providing better progress feedback during long installs Improve how we detect whether an NPM install is necessary Get npm install during wasp start to output more details.
In summary, Wasp runs npm install when it detects missing or changed dependencies, and this is not random but based on dependency tracking and project state. However, the process can feel opaque due to limited output and the time it takes, especially on resource-constrained environments.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Landyn, 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?
Hey,
migrate-dev
needs to build the application if it's not built first. It could be due to that.
Do you have any additional info when it is happening?Hey franjo, it seemed to be somewhat random and I've had a few failures getting the packages. I knew the AI bot would have answered so it was more of a curiosity than an issue.
I should have marked as resolved.
Thanks!