I have currently made a repository on GitHub and I am using react redux to make a small app example.
I have installed the necessary requirements that it works for me, but if I clone my app, I get a warning, react-scripts: command not found. I am a little confused at what I have done wrong. Surely if I installed yarn into my project, shouldn't it be available for someone to immediately look at it using yarn start?
If your node_modules folder is in .gitignore file then you have to re-install the dependencies.
After cloning the repository,make sure to enter into the cloned directory using:-
cd cloned-directory
And then run:-
yarn
And then run:-
yarn start
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 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 try to work on a yeoman project with a team. After generating the angularjs code with > yo angular and pushed the folder to github
git add .
git push
git commit origin master
and when I clone the code from git github I have this error
Fatal error: Unable to find local grunt.
If you're seeing this message, either a Gruntfile wasn't found or
grunt hasn't been installed locally to your project. For more
information about installing and configuring grunt, please see the
Getting Started guide:
http://gruntjs.com/getting-started
so I deleted every thing from .gitignore and pushed everything again, I had this warning
The file will have its original line endings in your working
directory.
So I am quite sure it's not going to work and it's not the best way to do it. Can someone help me on how to upload the yeoman project ?
I think that angular generator for Yeoman already creates a package.json file with grunt defined as dependency along with all its task. So the correct way to compile a project after the clone is to install all npm dependencies locally using:
npm install
then run grunt to compile everything:
grunt
Of course you must have grunt-cli globally installed, which is used to run grunt locally. To install it you have to use the following command where -g defined the global install (default is local):
npm install -g grunt-cli
First of all, i think you have a typo in your question, you have mixed commit and push commands:
git add .
git commit -m 'commit message' // message is optional
git push origin master
First message appears because you don't have an installed Grunt. Install it in your working directory:
npm install grunt --save-dev
Starting with Grunt v0.4, you should never install Grunt itself
globally. For more information about why, please read this. Source: grunt-cli docs.
If it is alredy listed in the devDependencies, just run:
npm install
The second one is caused by line-endings. It is a good practice to include .gitattributes file in your repo. File's content should be:
* text=auto
Read about this file: docs. Or there is another method. It is described in this question.
I started today working with gamejs for a small project. I saw that most project are repository files on github dot com, so I downloaded the github for windows and the git bash.
Then I used git bash to clone gamejs repository. I proceed the same with some repository stuff. However, it seems that I forget to install something... because I cannot start the server, I have gjs-server.sh or .cmd missing. The bash doesnt recognize the command. What will I do?
Since you cloned the code instead of downloading the release tarball you need to build GameJS first:
Change into the GameJs directory
cd gamejs
Get all needed submodules with git:
git submodule init git submodule update
Compile RingoJs:
ant -f ./server/ringojs/build.xml jar
EDIT: Prior to building you need to install Apache Ant build tool. Since it is a Java application to install it just download the binary distribution from their download page and unzip it.
Jekyll is processing my _plugins folder fine on my local machine (OS X 10.7.4, ruby 1.9.3), but it's not processing them on the server (Ubuntu 12.04, ruby 1.9.3). Both have the same version of Jekyll installed (0.11.2).
I'm trying to use the generate_sitemap plugin, here.
I'm deploying via git and the post-receive hook, which looks like this:
#!/bin/bash -l
GIT_REPO=/my_repo.git
TMP_GIT_CLONE=/my_temp_folder/
PUBLIC_WWW=/my_public_folder/
git clone $GIT_REPO $TMP_GIT_CLONE
jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit
I am seeing this error when I deploy:
remote: /home/ed/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
But, from what I've read, that's a Maruku warning and has nothing to do with the plugins.
Anybody have any ideas about what I can try to figure this out? I'm at a bit of a loss.
It's very hard to debug with Jekyll, but it's a great tool !!!
I assume you have more than one plugin in your _plugins folder.
So maybe one or some of your plugins , cause the problem.
If I'm right, you can do the following :
Kill your Jekyll
Create a backup of your plugins in another location (not in _plugins
folder).
Leave just one plugin in your _plugins folder and start Jekyll.
If it works , copy another plugin to the _plugins folder, until you
find the one which fails the Jekyll.
When you find it, you can add debug printouts to the problematic plugin (that's what I did).
Something like :
puts "before .... "
I have built the http://www.cloudifysource.org/ only with Jekyll and you can find and use lots of our useful examples in our GitHub repo : https://github.com/CloudifySource/cloudifysource.github.com
I had the same problem with Jekyll not loading plugins when called from the post-receive hook.
As is mentioned in the comments above, changing the current working directory to $TMP_GIT_CLONE does the trick.
You don't have to change anything in _config.yml.
#!/bin/bash -l
GIT_REPO=/my_repo.git
TMP_GIT_CLONE=/my_temp_folder/
PUBLIC_WWW=/my_public_folder/
git clone $GIT_REPO $TMP_GIT_CLONE
cd $TMP_GIT_CLONE # move to the temp dir
jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
cd # move back to allow deletion
rm -Rf $TMP_GIT_CLONE
exit
This is a real head-scratcher seeing as executing the original post-receive hook manually as the git user works just fine... Anyway, Jekyll is now loading plugins on my server and hopefully making this a proper answer will help others to find this solution.
Lately, I start to build https://github.com/alswl/code-standards-jekyll with jekyll.
I write two plugins in _plugins, and I found it was hard to debug.
At first, I use puts "balabala" to debug, it seems work.But once I met problem that didn't generate anything in the _site folder, and there was no 'balabala' in the console, I was panic.
After I read the jekyll source, I try to set auto=false in _config.yml, running jekyll will produce some debug trace stack error. Thank godness.
So, ues auto=false will help you to debug plugins.