3👍
A vue project uses a package manager (typically npm
or yarn
). This means it loads the packages based on what’s specified in package.json
when it serves and/or builds. The package manager might use its internal cache to provide the actual code.
So far you have only modified the source files of the package, not the output. And it’s the built output that gets used in your project, just as in your project, when you build, you’re deploying the contents of the /dist/
folder, not what you have in src/
.
The simplest way to achieve what you want is:
- fork the package into your github account
- commit and push the changes (depending on package this might involve building the package – look for the package’s
package.json
‘s"build"
script) - (totally optional and typically more involved) if it’s a useful change (a bugfix, etc…) consider PR-ing it in the original package. It might get merged. Most package authors are happy to accept useful additions, especially if they don’t break existing functionality.
- now go to your project’s
package.json
and replace the version with your fork, like this (assuming the package isvue-multiselect
and the fork branch you want isdevelop
. Don’t forget to replaceyour-username
with your actual github username. if you don’t specify a branch it will load the one that’s set as default in your fork – in github project settings):
"vue-multiselect": "github:your-username/vue-multiselect#develop"
- run
npm i
to apply the change.
Important note: you don’t need to create a pull-request and for it to be merged in order for this to work. In fact, if you do PR and it gets merged, that’s the point where you can switch back to the original package, provided you point to a version containing the mods.
Additional note: it is possible to get local changes to the package apply in your project (to test they work properly) by running npm run build
in the package folder, in node_modules/
. But if you build the project on any other machine it won’t contain the mods. Not until you point the package in package.json
to a version/fork containing the mods.
As a rule of thumb, you should treat all your projects as if before any serve
(or build
) you have deleted node_modules
and ran npm i
.
- [Vuejs]-How to pass a variable by prop and not allow child to change it ( vue 2 )
- [Vuejs]-Print array in method in vue.js