How to generate a new project using an older dfx version?

For example 0.7.1 instead of 0.8.4.

I have the older version in my dfx cache (verified with dfx cache list), but there isn’t a dfx cache use 0.7.1 or a dfx new <project_name> --version 0.7.1 command…

Can’t you just change dfx version in dfx.json?

I could, but the initial project files (including the webpack.config.js) will still be generated using the newer version. If I then change the version in dfx.json to an older version, everything breaks because the initial project files aren’t compatible with the older dfx version.

Another separate use case: what if I wanted to run some dfx commands using v0.7.1? What’s the point of storing all the older versions in the dfx cache if I can’t use them?

Ummm, have you tried in an empty directory with a dfx.json that has the older version, it’s working for me and generates the old webpack configs as well

You can set the dfx version in the environment variable DFX_VERSION.

The following command generates a new project with dfx 0.7.1:
DFX_VERSION=0.7.1 dfx new <project_name>

1 Like