What is the current behavior?
Running yarn global add . in the directory of a local module results in:
[1/4] Resolving packages...
error Received malformed response from registry for undefined. The registry may be down.
What is the expected behavior?
This may or may not be a question/feature request, but I'm intending to perform the equivalent to
npm install -g .
whereby the local module would be installed from the local code base to exist as a globally installed module. Is this currently possible?
Please mention your node.js, yarn and operating system version.
Yarn: 0.23.2
Node: 6.10.2
OS: elementary OS Loki
@bestander triage; This sounds like missing NPM compatibility / feature request.
NPM documents this behavior here:
npm install (in package directory, no arguments):
Install the dependencies in the local node_modules folder.
In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.
To add to this, yarn global add file:$PWD is not the same as npm install -g . as it copies the project and reinstalls all dependencies as opposed to just symlinking it.
Just confirmed that this is still an issue. Any help welcome.
I'd been keen to fix this up, if someone could give me some guidance. Just hit it.
If it's not obvious, the workaround is mentioned in @kozhevnikov comment:
yarn global add file:$PWD adds a local package as a global package using yarn v1.10.1
It's also worth noting that npm i -g . actually behaves more like yarn global add link:$PWD
Doesn't work with workspaces:
workspace-root$ yarn global add link:./package1
// -- snip
warning "[email protected]" has no binaries
Done in 2.40s.
workspace-root$
Obviously package1 has binaries, and the version is not 0.0.0
Running in the dir:
workspace-root/package1$ yarn global add link:$PWD
// --- snip
error Couldn't find package "@scope/package2@*" required by "link:/workspace-root/package1" on the "npm" registry.
workspace-root/package1$
Obviously package2 is a dependency of package1 and it's defined in the same workspace.
Most helpful comment
If it's not obvious, the workaround is mentioned in @kozhevnikov comment:
yarn global add file:$PWDadds a local package as a global package usingyarn v1.10.1