I want to start contributing to material-ui but before I submit a Pull Request I'd like to visually confirm that my changes have the desired effect. I followed the "install" page at material-ui.com and now I can run docs locally but I'm not sure what that does for me. I'd like to make a new barebones project that uses the material-ui that I have forked. Ideally it would use the material-ui that is on my local machine and not in my remote repo (this would allow me to make quick changes locally rather than having to push every time I want to see the consequences of a change). Is this possible?
You can use npm link to create a material-ui symbolic link inside node_modules that actually points to your forked version's physical folder. https://docs.npmjs.com/cli/link
Example:
cd ~/projects/material-ui # go into your forked directory
npm link # creates global link
cd ~/projects/my_project # go into your project directory
npm link material-ui # link-install the package
Related
When I was working on an open source project on GitHub Clone, there was a problem with executing Yarn Install, what caused it?
English is not my native language; please excuse typing errors.
It looks like your project references a npm package that isn't publicly available.
"#zeeis/velectron": "^17.0.0"
That prefix is mapped in their .npmrc to a GitHub Packages repo which we can also see in your log file, and you don't have the proper credentials to access that. It is also mentioned in one of their build files as being available at https://github.com/zeeis/velectron/releases/download/ which also isn't public.
I couldn't find any information about what that package is on GitHub or even Google so it seems to be an internal component. You might want to raise an issue in the projects repository to see if they will make all components required to build available to the public.
I'm honestly not even sure I would call this project "open source" right now since not anyone can get the sources and build the application for themselves.
You can try below solutions.
just execute npm install
Delete yarn-lock file.
npm logout
I'm getting used to Go, and trying to understand how it works.
So I'm trying to run the test code from my repository zoonoo/go-ethereum, forked from the original repository ethereum/go-ethereum.
When I run go test . under the eth directory, I get the following error :
eth/api.go:37:2: use of internal package not allowed
37th line of eth/api.go is as follows : "github.com/ethereum/go-ethereum/internal/ethapi"
Does this mean when you fork a go repository, you have to change the path of all dependencies within the code to run the code?
Does Go package system support repository fork at all?
As illustrated in another Go project:
Cloning a fork
If you wish to work with fork of InfluxDB, your own fork for example, you must still follow the directory structure above. But instead of cloning the main repo, instead clone your fork. Follow the steps below to work with a fork:
export GOPATH=$HOME/gocodez
mkdir -p $GOPATH/src/github.com/influxdb
cd $GOPATH/src/github.com/influxdb
git clone git#github.com:<username>/influxdb
Retaining the directory structure $GOPATH/src/github.com/influxdb is necessary so that Go imports work correctly.
Replace InfluxDB name/URL by your project, and the same idea applies.
In your case, the GitHub fork is only there for you to push your contribution back to it, and to make Pull request from it.
It won't serve as a source for go get to work, since the packages wouldn't match your GitHub for repo URL.
This is because internal packages in go can only be imported by packages in the same directory root. It's kind of like package private classes in java. If you want to edit the code without having to rename all package imports you need to maintain the same folder structure that the package expects so if github.com/zoonoo/go-ethereum is in your $GOPATH rename the directory to github.com/ethereum/go-ethereum or create a symbolic link and work from the linked directory instead.
I'm using a module for my angular app called angular-translate. However, I've had to make a few small modifications to the source code to get everything working the way I'd like, and now I want to persist those changes on npm install. A colleague suggested that I fork the repo of the source code and point to my forked repo as a dependency, which I've tried in these ways, e.g.
npm install https://github.com/myRepo/angular-translate
npm install https://github.com/myRepo/angular-translate/archive/master.tar.gz
The first gives me a directory like this with no build. Just a package.json, .npmignore, and some markdown files
-angular-translate
.npmignore
.nvmrc
CHANGELOG.md
package.json
etc
The second npm install gives me the full repo, but again I don't get a build like when I use the command npm install angular-translate. I've seen some dicussion of running the prepublish script, but I'm not sure how to do this when installing all the modules. I've also tried publishing the fork as my own module to the npm registry, but again I get no build, and I'm not sure that's the right thing to do...
I apologise for my ignorance on the topic. I don't have a huge amount of experience with npm. Would love to get some feedback on this issue. It seems like it could be a common enough issue when modifications need to be made to a package's source code? Maybe there's a better solution?
Try npm install <ghusername>/<repoName>, where <ghUsername> is your GitHub username (without the #) and <repoName> is the name of the repository. That should correctly install it. You will most likely want to use the --save or --save-dev flag with the install command to save dependency in your package.json.
If that isn't working correctly, check the contents of your .npmignore file.
Don't panic if the install command takes a long time; installing from a git repository is slower than installing from the npm registry.
Edit:
Your problem is that in your case, dist/ is not committed to the repo (since it is in the .gitignore). That is where the actual code lives. dist/ is built from the files in src/ before the package is published to the npm registry, but dist/ is never committed to the repo.
It's ugly, but in this case you will have to remove dist/ from the .gitignore and then run:
npm run build
git add .
git commit
git push
(Ensure that you have run npm install first)
You then should be able to install from github.
There might be another way to do this using a prepare script, but I'm not sure if that's possible; I've never tried it. Edit: Cameron Tacklind has written an excellent answer detailing how to do this: https://stackoverflow.com/a/57829251/7127751
TL;DR use a prepare script
and don't forget package.json#files or .npmignore
Code published to npmjs.com is often not what's in the repository for the package. It is common to "compile" JavaScript source files into versions meant for general consumption in libraries. That's what's usually published to npmjs.com.
It is so common that it's a feature of npm to automatically run a "build" step before publishing (npm publish). This was originally called prepublish. It seems that Npm thought it would be handy to also run the prepublish script on an npm install since that was the standard way to initialize a development environment.
This ended up leading to some major confusion in the community. There are very long issues on Github about this.
In the end, in an effort to not change old behavior, they decided to add two more automatic scripts: prepublishOnly and prepare.
prepublishOnly does what you expect. It does not run on npm install. Many package maintainers just blindly switched to this.
But there was also this problem that people wanted to not depend on npmjs.com to distribute versions of packages. Git repositories were the natural choice. However it's common practice to not commit "compiled" files to git. That's what prepare was added to handle...
prepare is the correct way
If you have a repository with source files but a "build" step is necessary to use it,
prepare does exactly what you want in all cases (as of npm 4).
prepare: Run both BEFORE the package is packed and published, on local npm install without any arguments, and when installing git dependencies.
You can even put your build dependencies into devDependencies and they will be installed before prepare is executed.
Here is an example of a package of mine that uses this method.
Problems with .gitignore
There is one issue with this option that gets many people.
When preparing a dependency, Npm and Yarn will keep only the files that are listed in the files section of package.json.
One might see that files defaults to all files being included and think they're done.
What is easily missed is that .npmignore mostly overrides the files directive and, if .npmignore does not exist, .gitignore is used instead.
So, if you have your built files listed in .gitignore, like a sane person, and don't do anything else, prepare will seem broken.
If you fix files to only include the built files or add an empty .npmignore, you're all set.
My recommendation
Set files (or, by inversion, .npmignore) such that the only files actually published are those needed by users of the published package. Imho, there is no need to include uncompiled sources in published packages.
Original answer: https://stackoverflow.com/a/57503862/4612476
Update for those using npm 5:
As of npm#5, prepublish scripts are deprecated.
Use prepare for build steps and prepublishOnly for upload-only.
I found adding a "prepare": "npm run build" to scripts fixed all my problems.
Just use the command npm install git+https://git#github.com/myRepo/angular-translate.git. Thanks.
To piggyback off of #RyanZim's excellent answer, postinstall is definitely a valid option for this.
Either do one of the following:
Update the package.json in your forked repo to add a postinstall element to scripts. In here, run whatever you need to get the compiled output (Preferred).
Update your package.json, and add a postinstall that updates the necessary directory in node_modules.
If you've forked another persons repository, then it might be worth raising an issue to illustrate the issue that installing their package through GitHub does not work as it does not provide the necessary means to build the script. From there, they can either accept a PR to resolve this with a postinstall, or they can reject it and you can do #2.
If you are using yarn like me. Imagine that you want to use a package like this:
yarn add ghasemikasra39/gridfs-easy --save where the ghasemikasra39 is the username and gridfs-easy is the name of the repo
I have Go installed, setup, and running hello world; I followed these directions. My workspace is organized as follows:
gocode/
bin/
pkg/
src/
github.com/
my_username/
hello/
hello.go
anomalyzer/
algorithms.go
...
README.md
I would like to start using Go code from a forked GitHub repo, lytics/anomalyzer. How can I do this? I forked the repo and setup a local clone in github.com/anomalyzer/ as shown above. But from the github.com/anomalyzer/ dir I try go install and get the error message algorithms.go:5:2: cannot find package "github.com/drewlanenga/govector" in any of: ...(lists my GOPATH). It looks like I need to also clone the github.com/drewlanenga/govector, do I? Is there an automated way to get all the package dependencies?
To fetch remote packages, run the go get command. Because the go get command automatically fetches dependencies and does not fetch a package that already have have, you can run
go get github.com/lytics/anomalyzer
to get everything setup including the github.com/drewlanenga/govector package.
so I'm working with PhoneGap on Eclipse and I'm having some issues "building the directory" to start programming. I'm following the steps from the original page but I don't understand some points (I'm Spanish and maybe it's a language problem) I usually can manage with it but after some tries this time I don't have any other chance than asking.
So this is the tutorial page https://github.com/davejohnson/phonegap-plugin-facebook-connect I'm stuck on the Android part.
3.- You'll need to build + include the Facebook Android SDK and build + patch the Facebook JavaScript SDK:
-First run *git submodule update --init* to initialize and pull down the versions of the JS and Android Facebook SDKs that work with this plugin; they will end up under lib/.
-Next, build the JS file. cd lib/facebook-js-sdk and run php all.js.php >> ../facebook_js_sdk.js. This will create the JS SDK file under lib/facebook_js_sdk.js. Please note: the output filename is important as the patch assumes that filename!
-cd .. and apply the patch file by running patch < facebook-js-patch.
This is the command git submodule update --init. I'm not sure where to run it, i've tryied on the terminal in all the proyect directories but it's allways returning the same problem: fatal: Not a git repository (or any of the parent directories): .git
If someone knows about this and can help me, i'd be so gratefull!!
Thank you.
Unfortunately those build instructions are old and need to be updated as the remainder of the steps do not work. Also if you are using the latest phonegap (now cordova-1.5.0.js) you will again run into problems.
If you're on a mac, this will be easy. Just hit up the github link you supplied above. Click the "clone in mac" button. You must have github for mac installed first! Once you do so, choose the place where you want it cloned and begin the clone. Now you have the latest from master. Since I'm using the cordova (latest phonegap build), I need the cordovachanges branch. In the github app you should be able to click branches > drop down on the cordovachanges branch and switch to it. Now all the plugin code should be mainly up to date. They're still patching and fixing things.
Follow the new directions. When you get to the build + include part, just open terminal, cd to the place where the git project was cloned to and "git submodule update --init" which will update the submodules. From there, the directions should work.