I want to install #nuxtjs/axios, but from my fork
url - https://github.com/BjornMelgaard/modules
branch - axios_vue_overlap_fix
package name - #nuxtjs/axios
what command should I use?
EDIT: This question originally had both npm and yarn tags. I'll leave this in case someone else finds it useful.
As far as I understand, npm maps GitHub packages to repository roots. Since the nuxtjs "modules" repository appears to be pile of largely-independent packages, you might have to jump through some hoops.
I got it working this way.
Install your whole fork, note the git+https syntax, and the branch identifier # following the repo URL:
npm install git+https://git#github.com/BjornMelgaard/modules#axios_vue_overlap_fix
Then npm install the dependencies of the axios module (because of the repo structure, npm will not do this for you):
cd node_modules/#nuxtjs/modules/modules/axios && npm install
And require it like so:
const axios = require('#nuxtjs/modules/modules/axios')
Related
In package.json, I have:
"vue-search-select": "github:my-github-account/vue-search-select"
And then run npm install, no error.
In app.js, I try to import the forked package:
import { ModelSelect } from 'vue-search-select';
When I run npm run watch, got the below message:
Module not found: Error: Can't resolve 'vue-search-select'
UPDATE:
I compared the original version and forked version in node_modules: Original contains dist folder but forked version don't have. In github, the original one also don't have this folder. And dist is included in .gitignore.
I understand that, for package.json GitHub URL, As of version 1.1.65, you can refer to GitHub URLs as just foo:user/foo-project, as seen here.
But I would still recommend a more complete URL instead:
git+ssh://user#hostname:project.git#commit-ish
git+ssh://user#hostname/project.git#commit-ish
git+http://user#hostname/project/blah.git#commit-ish
git+https://user#hostname/project/blah.git#commit-ish
That way, you control the scheme (HTTPS or SSH) and can check which credentials (cached username/password for HTTPS or private key for SSH) is used.
The OP Wilson comments in the discussion that adding dist/ to the repo could be an option, as in here.
A prepare script can be declared in the package.json, such as this one.
"scripts": {
"build": "tsc",
"prepare": "npm run build"
},
As noted in Wilson's answer
the important thing is that the prepare script is added in forked package, not in the project that using the package.
Finally, I found a solution:
Add "prepare": "npm run lib:build" (or something else depends on the package how to build, can check it in package.json) to scripts of package.json to the forked package. And push to github.
Then, in the project that using the forked package, just keep "package-name": "github:my-github-account/package-name" in package.json and run npm install again. No other changes.
Using npm link in local development is very helpful when we're doing debugging on some packages.
You could just clone the repo into your local and then you can link them in your main app that consumes them.
What is the equivalent of npm link in Golang?
Thanks in advance!
You should look at go mod vendor. While it is not identical to npm link which creates a symbolic link to module, it provides a similar developer experience where dependencies are copied into /vendor directory of project similar node_modules of npm.
More documentation here: Making vendored copies of dependencies
I've created an NPM Package on TFS (because my organisation uses TFS instead of normal git/gitbucket/gitlab), that I want to install to other projects.
On Github all I needed to do this was:
$ npm install git.com/username/privateRepoName
but when I try:
$ npm install tfs.organisationname.net/reponame
I get the following error:
npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be
invalid.
I've tried multiple methods for hours now on adding my credentials (yes, my windows credentials are the same as my TFS credentials) but i'm not seeming to win nor find the answer anywhere as every example is using git credentials and not TFS.
Does anyone know how I can do this?
npm install xxx can be seen as a shorthand for modifying package.json, where dependencies can be precised in four ways, as per the docs:
version range: "foo": "^1.0.0"
URL: "foo": "https://url.to/the/tarball/of/foo"
git URL: "foo": "https://url.to/foo.git"
github: "foo": "github-username/foo"
local path: "foo": "file:./path/to/the/foo/package"
NPM has built-ins for using private git repos as dependencies, but nothing for TLS.
Luckily, it provides a local path installation which will save you. Simply get the package locally, which you're able to do, make it a local dependency, and you're good to go.
The best way to tackle this since I have the rights to the TFS repository was to clone it then link it.
First $ git clone tfs.foo.com/repo into the project directory then read this doc.
When I try with
npm install vuetifyjs/vuetify#v1.5.2
I get "Cannot find package".
UPDATE:
There is a packages folder under which there is a vuetify directory.
I tried npm installing that folder. Everything appeared to go well until I started the dev server.
Now in the console log I see:
[Vuetify] Multiple instances of Vue detected
Seems to be related to https://github.com/vuetifyjs/vuetify/issues/4068 but I cannot tell what the solution is at this point.
I had the same issue to use my own version of Vuetify, waiting for my pull request being accepted.
Here what I did:
I build the vuetify project with my fix.
yarn
yarn build
Then I took the content of 'packages/vuetify' and put it in a new git repository. I remove the .gitignore to be able to commit built files (/es5, /lib, /lib-temp, /dist)
Finally I add this git repository to my project to replace my vuetify version:
npm install git+https://gitlab.com/GITLABUSERNAME/REPOSITORYNAME.git
Looking at the package.json file, the package doesn't have a name property, which it would need to have for you to be able to install it from GitHub.
So the short answer is that you can't install vuetify directly from GitHub via npm.
However, you can install it directly from npm:
npm install vuetify#1.5.2
You can't install vuetify directly from GitHub but you can edit code in 1 component node_modules/vuetify/lib/components/VSlider/VSlider.js Then, you install patch-package and execute path package vuetify Delete node modules and execute yarn to create new node modules Last, yarn serve, you see your code is work
https://www.npmjs.com/package/patch-package
I am just learning about yarn and npm.
I want to use a particular package that crashes my app. I found a project issue which looks like fix has been implemented and merged with master. A comment says npm package has not been updated yet.
I have added the package to my project:
yarn add react-widgets
I thought I could use yarn to add the package via git repository to get fixed version.
The package I want is
https://github.com/jquense/react-widgets
So I tried
yarn add https://github.com/jquense/react-widgets.git
I get error:
error Package "undefined#undefined" doesn't have a "name".
Firstly, is this error a problem with my use of yarn or a problem with react-widgets repository? I am assuming it should work to add it like this so please correct me if I am wrong.
Also, can I assume that if there is an updated npm package, that I will be able to update with yarn at that time?
I'm afraid it is impossible to do now. This git repo is actually several packages inside(main package is here) one repo and root package.json is not valid one - it doesn't have name description and this is fail reason. There is discussion about supporting this in yarn, but it hasn't been implemented yet(in npm too).