How to install meteor router package on Windows 7? - javascript

There is a Meteor router package that I need installed, but apparently I can't use meteorite, because meteorite doesn't work on windows.
Is there a way to install it in my meteor?

Create a directory called packages in your project folder
Example "/yourproject/packages"
Meteor router needs these three repositories in order to work properly.
Inside the packages folder git clone these repositories
git clone --recursive https://github.com/tmeasday/meteor-router.git
git clone --recursive https://github.com/tmeasday/meteor-page-js-ie-support.git
git clone --recursive https://github.com/tmeasday/meteor-HTML5-History-API.git
remove meteor and the folder strutures should look like this inside your packages folder
router
page-js-ie-support
HTML5-History-API
then meteor add router from your "/yourproject" directory

You need create package folder and download the package you want to
use by using git clone.
Some of the packages have dependencies so you need clone those
packages as well from the git.
Make sure you remove meteor from the downloaded directory.
Some times, git clone will not download the files completely so you have to go to the package directory where you did not get all the files and run 'git submodule update –init' and then reclone the package.
Now that you have all the required packages and changes directory to proper name and all files are available, go back to project root directory and run
meteor add packagename
Here are some of the references for this
http://csharprambling.wordpress.com/2014/04/24/adding-meteor-package-in-windows/
https://www.discovermeteor.com/blog/using-meteor-and-atmopshere-on-windows/

You can just simply download it to /yourproject/packages/ folder

Related

Publish Angular library dist folder on a separate git

I have an Angular library that i use in another project. I build my library with the following command:
ng build
Which creates a dist/my-library directory at the library root. I want to publish the dist content on a separate git repository so that it can be consumed directly by other projects.
I have created a git submodule but when i do a build and enter the dist directory, git doesn't see any changes. If i do:
git submodule update
it will detect changes but it will be detached from head, so i can't publish changes on the master branch.
The weird thing is that i managed to get it to work a few times by pure luck, so it must be a viable solution.
How can i get git to publish the content of the dist folder on the dedicated repository?
I found this which works:
ng build
echo "gitdir: ../../.git/modules/dist/ngx-mylib" > dist/ngx-mylib/.git
Now when i go in my dist folder i can do a git add, commit and push. But i don't know what it does exactly so feel free to elaborate.

yarn publish <folder>.gitignore overriding .npmignore

I'm trying to publish a module I have created.
The module has multiple entries in it and I want to publish from within my build folder.
Every time I try to publish with yarn. I get:
Output:
The following paths are ignored by one of your .gitignore files:
build/package.json
Use -f if you really want to add them.
I tried yarn publish build
And also cd build && yarn publish where I copy the package.json and npmignore and all the relevant files.
It's always the same result.
I have a .gitignore in my root and an .npmignore in my root.
If I publish the build folder from the root it works but I dont want the path to include the build/lib folder.
If I do yarn build && cd build && npm publish && cd ../ that will also work.
But I'd rather use yarn.
Does anyone have a solution for it?
All I want is to publish my already created build folder content. I have all the needed files there.
EDIT
After much research and looking into other packages,
I ended up just creating a small copy script that copies my essential files to a build folder and clears up my package.json from all unwanted items.
Then my ci publishes from the build folder.
That was our solution that we've implemented

How to verify an object instance? instanceof and ....prototype.isPrototypeOf(...) are not reliable [duplicate]

Whenever I make projects, I have to download all dependencies of node modules. Without copying the node_modules, Is there anyway to share the central node_modules in multiple projects?
like the followings, I have to run many commands every time..
npm install gulp-usemin
npm install gulp-wrap
npm install gulp-connect
npm install gulp-watch
npm install gulp-minify-css
npm install gulp-uglify
npm install gulp-concat
npm install gulp-less
npm install gulp-rename
npm install gulp-minify-html
You absolutely can share a node_modules directory amongst projects.
From node's documentation:
If the module identifier passed to require() is not a native module,
and does not begin with '/', '../', or './', then node starts at the
parent directory of the current module, and adds /node_modules, and
attempts to load the module from that location.
If it is not found there, then it moves to the parent directory, and
so on, until the root of the file system is reached.
For example, if the file at '/home/ry/projects/foo.js' called
require('bar.js'), then node would look in the following locations, in
this order:
/home/ry/projects/node_modules/bar.js /home/ry/node_modules/bar.js
/home/node_modules/bar.js /node_modules/bar.js
So just put a node_modules folder inside your projects directory and put in whatever modules you want. Just require them like normal. When node doesn't find a node_modules directory in your project folder, it will check the parent folder automatically. So make your directory structure like this:
-myProjects
--node_modules
--myproject1
---sub-project
--myproject2
So like this, even your sub-project's dependencies can draw on your main node_modules repository.
One drawback to doing it this way is you will have to build out your package.json file manually (unless someone knows a way to automate this with grunt or something). When you install your packages and add the --save arg to an npm install command it automatically appends it to the dependencies section or your package.json, which is convenient.
Try pnpm instead of npm.
pnpm uses hard links and symlinks to save one version of a module only ever once on a disk.
If you have npm installed, you can install in your terminal with:
npm install -g pnpm
To update your existing installations (and sub-directories) use:
pnpm recursive install
Or use the shorthand command (leave off -r if you need to target only one directory)
pnpm -r i
One helpful note: You may find some rare packages don't have all their dependencies defined. They might rely on the flat node_modules file directory structure of npm or yarn installs. If you run into issues of missing dependencies, use this command to hoist all the sub dependencies into a flat-file structure:
pnpm install --shamefully-hoist
It's best to avoid using the --shamefully-hoist flag as it defeats the purpose of using pnpm in the first place, so try using the command pnpm i your-missing-package first (See pnpm FAQ).
I found a trick, just take a look at the Symbolic Links (symlinks) on Windows or Linux, it is working just like shortcuts but more powerful.
Simply you need to make a Junction for your node_modules folder anywhere you want. The junction is nothing but a short cut to your original node_modules folder. Create it inside your project folder where the actual node_modules would have been created if used npm install.
To achieve this you need at least one node_modules real folder then make a Junction to it in the other projects.
On Windows, you can either use the Command Prompt, or use an application. Using the Command Prompt gives you a bit more control, using an application is easier I suggest Link Shell Extension.
Main directory should look like this
node_modules
Project 1
Project 2
Project 3
Project 4
just open the file Project 1/.angular-cli.json
change the schema
"$schema": "./node_modules/#angular/cli/lib/config/schema.json",
to
"$schema": "./../node_modules/#angular/cli/lib/config/schema.json"
and don't forget to create node_modules empty folder inside your project directory
See also npm v7.0.0's support for workspaces
RFC
https://github.com/npm/rfcs/blob/latest/implemented/0026-workspaces.md
Documentation
https://docs.npmjs.com/cli/v7/using-npm/workspaces
By looking at some articles it seems that Lerna
is a good tool for managing multiple projects inside a single directory (monorepo). It supports modules sharing without duplicating the entire packages in every folder and commands to install them in multiple projects.
Javascript monorepos
Monorepos by example
Building large scale apps in a monorepo
pnpm is also a simple and efficient tool, which doesn't duplicate those modules which are already installed for other projects.
Let's assume that having a single node_modules it should contain all the packages for all applications. thus your apps will also share most of the unique package.json entries (just the name should change)
my idea would be to have a single root and multiple src level as below
root\package.json
root\node_modules
root\\..
root\app1\src\\..
root\app2\src\\..
the only issue you might face would be having a backup of json (or tsconfig) for any app and restore them when you work on it or setup your startup scripts to serve any app

Using stellar-lib api with Meteor

this is probably a silly question but am new to Meteor and struggling a bit. I want to build a stellar app that tweets when you get stellar. There is a nice Javascript API stellar-lib that works on node, but im unsure how to access the modules in Meteor...
I'm also building an app with Meteor and stellar-lib and have found two options:
1) You can manually copy over the built stellar-lib.js or stellar-lib-min.js from the build/ directory from either the github repo or the node_modules folder you installed it to when you ran the npm install command.
If you do this, you will have to copy the .js file to client/compatibility, otherwise stellar-lib will not work (note: this means you can only use Stellar on the client).
2) If you need it on the server, you can also have browserify wrap stellar-lib for you, then copy the output to lib/ in your Meteor app's root directory. I did this in my repo here with gulp.
Here's a short explanation to how 2) works:
.gulp is where I'll install my NPM modules where they will be ignored by the Meteor build environment (because the folder is hidden).
In deps.js, I require the modules I would want to use in my Meteor app as I would if I was using them in a traditional node.js app. package.json defines the modules I'll install with NPM and the gulpfile.js describes a build task that will resolve my require statements and output a single deps.js file that includes my dependencies to my Meteor app's lib/ folder.

Yo generator subgenerator not available. When doing an NPM install it doesn't pull all the code down

I'm working on creating an Yo generator to generate hapijs modules. I've published this to NPM and when I create a new project and do an npm install generator-hapijs, it doesn't pull all the code down into my node_modules/generator-hapijs directory and therefore my subgenerator is not available when doing a yo --help. Why not and how can I fix this?
Here's my code: https://github.com/toymachiner62/generator-hapijs
Here's what's available in my node_modules/generator-hapijs folder when installing this package in a new project:
-/project
--/node_modules
---/generator-hapijs
----/app
----/node_modules
----package.json
----README.md
It had nothing to do with yeoman and yo, but rather had to do with the fact that I had a files array in my package.json and it only contained app so when installing it only installed files from the /app folder.
I just removed the files array from my package.json file.

Categories

Resources