How to downgrade the npm version shipped with the standard ddev setup? There are multiple ways of doing this.
- You can use the ddev's hook system for running the command. In your
config.yamladd the following configuration:
- exec: "npm i -g npm@6"
The downside of this approach is that the command is run every time you start your ddev environment. This can be annoying as you have to wait for quite a while until the downgrade has finished.
- You can extend the project's Dockerfile with the logic to downgrade npm. This will be executed just once during the image build process. Add a new file
.ddev/web-build/Dockerfileto your project with the following content:
RUN npm i -g npm@6
We went for the solution to add the Dockerfile to avoid having to wait for the npm downgrade each time the ddev project gets started.
It would be beneficial to have a configuration option for ddev to install a specific version of npm. That's why we've opened an issue on GitHub.