Yarn: Feature request: Only install devDependencies

Created on 13 Oct 2016  路  12Comments  路  Source: yarnpkg/yarn

Do you want to request a _feature_ or report a _bug_?

Feature

What is the current behavior?

dependencies are always installed and there is no command to prevent that.

What is the expected behavior?

Similar to npm install --only=dev a CLI option to only install devDependencies.

(My) usecase: Compile only environments where the resulting build will be used in a docker container (with a separate yarn install)

cat-feature needs-discussion triaged

Most helpful comment

Is this still an open request? If so, I was going to take a swing at it.

All 12 comments

Is this still an open request? If so, I was going to take a swing at it.

Go ahead @coreyc.

@coreyc This would be incredibly cool. I have a "helper package" which has 20-30 dependencies in production, but locally I only need two devDependencies.

Actually we are having an issue that could be solved by this feature.
We are using docker-compose with 2 services one to compile (webpack) and one to run the server (web) and a shared volume for the build output.
The issue arise because we use a .env file to pass NODE_ENV var to both services

if we set NODE_ENV=production to test production behaviour the webpack service isn't able to compile because yarn will install only dependencies.

So the solution we are adopting is this in the webpack service:
command: bash -c "NODE_ENV=development yarn && NODE_ENV=production npm run build"

It would be cool if we could specify to force install devDependencies even if NODE_ENV=production

@SharpEdgeMarshall I think this feature is slightly different than what you're talking about, but will take a look at it.

Due to holiday week, been slightly delayed but I am working on this.

I noticed after commenting that the feature requested by @peterjuras could completely solve our issue, exactly as him we have a build container and we could use ONLY devDepencies.
With --dev flag our cmd could became command: bash -c "yarn --dev && npm run build"

@SharpEdgeMarshall I ran into something similar on Heroku, which sets both NODE_ENV and NPM_CONFIG_PRODUCTION variables. I think #1975 would help your case too.

In npm, NPM_CONFIG_PRODUCTION takes precedence over NODE_ENV for whether to install devDependencies. In Yarn, it's currently the opposite.

@coreyc Thanks for the PR. Will you have time to finish it or would it be best to have someone else give it a try?

@nsgundy I had some open questions that weren't answered in the PR comments. Re-familiarizing myself with the code now. Will update the PR soon.

@nsgundy thought i could spare some time to finish this, but can't make the time. you can look at the PR, it's close to being finished anyway.

+1 would love to see this!

Was this page helpful?
0 / 5 - 0 ratings