yarn icon indicating copy to clipboard operation
yarn copied to clipboard

Support for specifying package.json path?

Open jleclanche opened this issue 8 years ago • 10 comments

I'm sorry if this has been asked before, but I can't find it in the issue list.

How can I specify the path to a (local) package.json? When deploying apps with eg. ansible, the way yarn works right now forces messing about with cwd, not ideal.

npm supports the -C flag to npm install which sets the current working directory; not ideal either but better than nothing.

yarn 0.19.1

jleclanche avatar Jan 21 '17 20:01 jleclanche

+1

sdwvit avatar May 19 '17 15:05 sdwvit

@jleclanche Were you able to figure this out? I am stuck on the same issue.

monarajhans avatar Jul 07 '17 01:07 monarajhans

Nope. using cwd overrides.

jleclanche avatar Jul 07 '17 01:07 jleclanche

Hey @jleclanche, I think my issues were because $(yarn bin) was not in the path when invoking scripts in package.json. I fixed this by doing the following:

#client/package.json "scripts": { "postinstall": "echo "Postinstall running - client/package.json"",

#config/deploy/feature.rb (this should be production.rb if you are trying to deploy it to production environment) set :yarn_flags, '--production'

#package.json "scripts": { "postinstall": "cd client && npm install && echo "Postinstall running"",

Let me know if this helps.

monarajhans avatar Jul 07 '17 17:07 monarajhans

Can you provide more details about why and how you need this and about your environment so we can assess?

BYK avatar Jul 10 '17 14:07 BYK

@BYK this is needed for example if we want to avoid using cwd directives when deploying using eg. ansible, or anything else that is cwd-agnostic.

jleclanche avatar Jul 10 '17 14:07 jleclanche

@jleclanche what's wrong with using cwd, though? Because I'm pretty sure even if we introduce this feature, I'm guessing we'd do the switching internally.

BYK avatar Jul 10 '17 14:07 BYK

@BYK In my case I want to run unit tests with multiple dependency versions

sbergot avatar Aug 09 '17 09:08 sbergot

Can you provide more details about why and how you need this

Given this directory structure:

myproject
  \- package.json  # <- using workspaces package1 and package2
  \- package1
       \- package.json
  \- package2
       \- package.json

I was attempting a workaround for https://github.com/yarnpkg/yarn/issues/6715. I was hoping I could force the installer to only install the dependencies defined in package1/package.json into package1/node_modules with something like this:

# Pseudo code that I wish I could do:
cd package1
yarn install --modules-folder node_modules --package-file package.json

So I could test packages in isolation. Currently, only everything defined in myproject/package.json is installed. If I delete myproject/package.json then I can run yarn install and it does what I wish it would do even if I had not deleted that file ;)

I just wanted to mention my use-case, it will eventually be solved when that other issue with the --focus flag is solved.

Thank you for your hard work!

mmzoo avatar Nov 28 '18 12:11 mmzoo

My projects often involve a nested example/ project within a larger application. But yarn init -2 fails to see the package.json file in the current working directory (example). Instead, it completely ignores that and changes the wrong file, ../package.json.

As well, yarn set version stable corrupts both files. It forces "packageManager": "[email protected]" into ../package.json and then proceeds to downgrade ./package.json back to v1.

Super not a fan of programs that try to machine automate changing primary source of truth configuration text files.

Finally, after attempting yarn install in the examples/ directory, then yarn gives a long winded explanation. In the middle of the explanation is a recommendation to (manually) initialize an empty yarn.lock file.

Neither the yarn tutorial nor yarn init did that properly. The tutorial made no mention of it. And yarn init blatantly ignored my current working directory just because an ancestor directory has a package.json file.

mcandre avatar Sep 26 '24 05:09 mcandre