NPM install part from github monorepo - npm

I'm trying to install typescript plugin from rollup plugins monorepo (actually a branch with a PR from this repo).
I guess the following command tries to install the whole repo:
npm install git+https://github.com/rollup/plugins.git.
It also fails at their disallow-npm.js, I guess a guard for this kind of thing.
How can I pull and install only one plugin from this monorepo?

relating to your problem I found an article that talks about installation of NPM modules from Github repos:
How to install NPM modules from Github Repos
Being more accurate to your question, that repo has a Readme on each package that you can use to install the modules from that Github repo.
npm install #rollup/plugin-alias
The code about should be valid to install the module "plugin-alias" from that "rollup" repo.
I hope this helps to solve your problem, regards.

Related

Is there a way to install an npm package locally but not affect package.json or package-lock.json?

I have a project that I'm working on for a client where I have two private packages (which I can't get access to npm install) are inside the package.json.
I do however have access to clone the repos for those said packages. If I simply run an npm install I'll get a permission denied error. Same if I run npm link to the packages.
I've been working around this by removing the packages from the package.json then running npm install ../some-package. This works but isn't a great solution because if I wanted to add a new package I'd have to deal with a bit of a mess with the package.json.
Is there a better way than this?
I have tried running npm link ../some-package but I still get access denied. The only way I've managed to complete an install is by removing the packages then installing them from a local dir.
I don't know the details of your situation, but I see at least two potential solutions to explore.
Option 1: Install the package from the repo
I do however have access to clone the repos for those said packages.
You can install from a git repo and package.json will record that git repo as the source of the package rather than the npm registry.
From the docs at https://docs.npmjs.com/cli/v8/commands/npm-install:
npm install :
Installs the package from the hosted git provider, cloning it with git. For a full git remote url, only that URL will be attempted.
Option 2: Install from the local file system with --no-save
If that approach doesn't work for you, you can try npm install --no-save ../some-package as a build step. The --no-save makes it so it doesn't modify package.json.

NPM dependency from Gitlab directly

I have a situation where there was an update in one of npm packages I use in my project, but author didn't publish it on npmjs registry, so up to date code sits in gitlab only.
What would be the best solution to get updated version of code? I believe there is a way to add dependency to project which will be downloaded from gitlab or github public repository directly? Is it possible to compile it like in npmjs as well?
Yes, you could install a dependency from a git repository directly. As can be seen in the npm docs. You can straight install a Git Remote repository like this:
npm install <git remote url>
e.g.
npm install git://github.com/npm/cli.git
But beware that installing directly from the source git might have unintended side effects (missing build files, additional documentation files in general changes to the npmjs Version).
Also installing from the repository I would recommend you install from a specific commit/Tag.

react-native-reanimated & react-navigation/drawer dependency error

I'm into a problem that I have already asked the discussions tab in the react-native-reanimated GitHub repository: this is the link in the github repo
I have cloned a react-native project and tried to install npm packages using npm install, but I have faced the error below
What I have done?
I have tried npm install --legacy-peer-deps, was not helpful
I have installed the packages from scratch, was not helpful
I have tried yarn to install packages the error was gone but the issue persisted
I have also tried configuring the flipper on the application but the app also does not
connect to the flipper
Any ideas and suggestions would be appreciated :)
This problem is going to be solved by just running npm with --legacy-peer-deps, this is going to tell the npm just don't do anything else except looking into the package-lock.json file and install the versions that you used to have in your node_modules folder.
npm install --legacy-peer-deps
I should mention that you are going to see this output while you are using npm version 7 or above.

How to install react-native-obfuscating-transformer from github

react-native-obfuscating-transformer is no longer updated in npm repository but it is still updated in github. So I would like to know how to install it step by step from github.
You can find the installation step in there GitHub repo itself.
If you are not able to install through npm and want to install directly from GitHub as an npm dependency, follow this article.

Replace an npm package with an alternative

Following up on Substitute an npm package with own implementation, which is about six years ago,
is there any simpler alternative now, with npm (not yarn, and not "transitive dependency")?
Basically, the same as NPM replace package with other, I found that I need package XXX, however, that package XXX has been out of maintenance for a year now, and I've found an updated git repo (but with the same name of package XXX).
Is there any easy way for npm to grab from the alternative git repo instead, or any simpler workarounds? (Not to start a language war but Go now has)
That updated git repo owner must have a simple way to make use of his own package without publishing to npm, so what's the trick?
npm install has a built in support to install package from github, gitlab, bitbucket, gist, and other special formats.
but you can install it from any git repository using the following
npm install <git repo url>
for more information, see npm install documentation