Initialization of node_modules in an existing project

I have the project in git and node_modules added to .gitignore.

The project is launched in docker and node_modules are initialized there. I haven’t found a good way to do this and am now calling the following command:

npm install --prefer-offline --no-audit --no-fund --production --legacy-peer-deps --loglevel=warn

Is there a better way?
What I don’t like about the current one is that it updates the yarn file and creates package-lock.json (which doesn’t exist by default). There is also an error:

npm ERR! code ETARGET
npm ERR! notarget No matching version found for @tryghost/email-content-generator@0.0.0.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

Any advice or help would be appreciated!