Do you want to request a feature or report a bug?
bug
What is the current behavior?
We use a git submodules to manage the common dependencies of our projects, in that folder there is a package.json that is referenced in the main app.
yarn produce this error
yarn install v0.16.1
info No lockfile found.
warning yarn.relative.imports: No license field
[1/4] 🔍 Resolving packages...
error "/Users/Zanza00/dev/github/yarn.relative.imports/typings/humanize-duration" doesn't exist.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
the actual path is in src/commons/typings
If the current behavior is a bug, please provide the steps to reproduce.
I have setup a skeleton app in this repo with steps to reproduce the issue
https://github.com/zanza00/yarn.relative.imports
What is the expected behavior?
npm can install and resolve the files so it can correctly install the project
Please mention your node.js, yarn and operating system version.
node: 6.9.1
npm: 3.10.8
yarn: 0.16.1
os: macOS 10.12.1
small update: after I upgraded both node and yarn I tried again (same repo), this time it's a different error
yarn install v0.17.8
info No lockfile found.
warning yarn.relative.imports: No license field
[1/4] 🔍 Resolving packages...
error "//src/commons" doesn't exist.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
__Versions__
node: 7.1.0
yarn: 0.17.8
os: macOS 10.12.1
I have a similar issue with relative paths in Yarn 0.17.10
With a folder structure like that :
yarn.relative.imports
|_ platform-root
| |_ common-components
|_ resources-root
|_ js-core
in _yarn.relative.imports/platform-root/common-components_ I execute
$yarn add "file:../../resources-root/js-core/"
yarn add v0.17.10
info No lockfile found.
warning yarn.relative.imports: No license field
[1/4] Resolving packages...
error "yarn.relative.imports/platform-root/js-core" doesn't exist.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
The path yarn is looking for doesn't exist because it should be looking for yarn.relative.imports/resources-root/js-core not yarn.relative.imports/platform-root/js-core
Versions
node: 6.9.1
yarn 0.17.10
os: debian 8.6
yep! here's my use case just for supporting infos/datas. i use lerna and have a mono repo:
🛰 salsa$ tree -L 1 packages
packages
├── senor-salsa-api
├── senor-salsa-common
├── senor-salsa-db
└── senor-salsa-ui
given that these are private packages, I don't want to publish them, so my package.jsons look like this
{
...
dependencies: {
"senor-salsa-common": "../senor-salsa-common"
}
}
and finally, the error:
🛰 senor-salsa-api$ yarn
yarn install v0.16.1
info No lockfile found.
[1/4] 🔍 Resolving packages...
error Couldn't find package "senor-salsa-common" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
In the meantime I have made a workaroud with preinstall script that reveals local paths and postinstall script that hides them again. Works with yarn and lerna. You can make up your own just like that or if you are interested I can post my solution somewhere.
@patotoma, that sounds great. can you share?
Actually I had just find out that in new yarn v0.20.3 you can use relative paths like:
"devDependencies": {
"helpers": "file:../../packages/helpers",
...
}
@cdaringe so you dont need to do that thing with revealing and hiding absolute paths in lerna repo anymore. But if you want to use yarn in lerna you have to bypass lernas bootstrap method with yarn install and calling yarn install and creating symlinks for each package by yourself. At least thats what I am doing. This is what my main package.json in lerna does look like:
{
"scripts": {
"postinstall": "lerna exec --concurrency=1 -- yarn; lerna exec --concurrency=1 -- linklocal"
},
"devDependencies": {
"lerna": "2.0.0-beta.37",
"linklocal": "^2.8.0"
}
}
Thanks @patotoma I have tried and it works for the first time.
With this line "zanza00.app.commons": "file:src/commons" yarn can install the dep without problems.
however after the install changes the import to "zanza00.app.commons": "file://src/commons" and with this new path it will fail.
@zanza00 have you tried file:./src/commons ? maybe that will do the trick
Same result, after the first successful install it changes the path to the wrong one :(
Removing file: prefix solved a problem we had where yarn install on windows would add ./ prefix to relative file paths, but yarn install on macOS would remove it.
Since v0.21.0 release,
file:prefix is not needed. See pull-request with fix and changelog.
- Piotr Lewandowski on stackoverflow
It worked for me using file:../package
file:./lib/common work . (package.json need version field!)
yarn version: 1.17.3
Most helpful comment
yep! here's my use case just for supporting infos/datas. i use lerna and have a mono repo:
given that these are private packages, I don't want to publish them, so my
package.jsons look like thisand finally, the error: