using npm link with web3 - npm

I'm trying to patch one of the web3 packages and use the patched version in my node script. I'm confused about what to use in the npm link program: web3 or web3.js.
Here's what I did:
Cloned the web3 repo.
Executed npm bootstrap (which linked web3 subpackages).
Ran npm link (which put a link to the web3.js folder into my global modules folder).
Created a project named web3test and ran npm install web3 for it.
Now I don't know how to link my project to the local copy of web3. If I run npm link web3, it puts a web3 folder in the global modules directory, which is not the same as my web3.js repository. But my project is supposed to use web3, not web3.js, so it doesn't make sense to link to web3.js.
I'm on Windows 10.

I realized that web is actually a package within web3.js. So I went into the \web3.js\packages\web3 directory and executed npm link from there. Of course, I had to also run npm build for the main package so that all web3 packages were built.

Related

Configure `.npmrc` to get one scoped package module from npm and the others from github packages

I'm using a scoped package in my application, some modules from it are stored on GitHub packages and the rest are in npm registry. Till now I was using only one module that is stored on GitHub, but now I need to install another one stored on npm.
Currently my .npmrc file looks like this:
registry=https://registry.npmjs.org/
#custompackage:registry=https://npm.pkg.github.com/
I want to inform npm to install specific scoped module from npm registry and keep installing others from GitHub packages. Updating .npmrc like this doesn't work (it continues looking the subpackage on GitHub):
registry=https://registry.npmjs.org/
#custompackage:registry=https://npm.pkg.github.com/
#custompackage/module1:registry=https://registry.npmjs.org/
Is it possible at all to configure .npmrc to get a part of scoped package modules from npm and the rest from GitHub pages?

How to link a globally installed node package to a project with yarn?

I have just started using yarn and I can't figure out how to link a globally installed package to a project. With npm I would just run npm link <package-name> but it doesn't work with yarn.
when I run yarn link <package-name> it gives this error:
yarn link v1.22.4
error No registered package found called "express".
info Visit https://yarnpkg.com/en/docs/cli/link for documentation about this command.
The link functionality is not really meant for linking global packages to a project. It is meant to link a package that you are working on to another project that you are working on. The fact, that the npm link command can be used to link globally installed packages to the current project is just an implementation detail of npm. From the yarn docs:
For the vast majority of packages it is considered a bad practice to have global dependencies because they are implicit. It is much better to add all of your dependencies locally so that they are explicit and anyone else using your project gets the same set of dependencies.
So you should just add the dependencies via yarn add <package-name>.

Install React-Admin package from specific branch or with open pull request

I am having difficulties trying to install a development branch of React-Admin packages with NPM in an active project, specifically:
ra-tree-ui-materialui
ra-tree-core
To have the changes made in this PR https://github.com/marmelab/react-admin/pull/3379
Is there any way of doing this in a similar way to how you normally would put this in package.json ("username/repo#branch")
It is difficult to install a local version of one of React Admin's package, because we use a mono-repository that contains all the packages.
I see two solutions to your needs.
Install the alpha builds
The core team had just published an alpha for the next version of React Admin. It's not stable yet, but you can try it by running :
npm install --save ra-tree-core#next
npm install --save ra-tree-ui-materialui#next
Install a local version for development
If you want to tweak the React Admin packages while you are using them, you can fork the whole repo and use symbolic links.
# On a separate folder
git clone git#github.com:marmelab/react-admin.git
cd react-admin
make install
make build
cd packages/ra-tree-core
npm link # This will make this package available for linking
And on your project, then run:
npm link ra-tree-core
This will create a symbolic link between your local ra-tree-core and your node_module folder.
I showed these examples with npm, but yarn link works too.

How to install npm own local packages?

I have 2 projects(packages) in npm, I want to inject package_A as dependency to package_B. In package_A root folder, I run npm install -g, then npm install it to C:\Users\Myuser\AppData\Roaming\npm\node_moduls\package_A folder. Now in packages.json in package_B I add "package_A": "1.0.0" in dependencies. When in package_B root file I run npm install, its failed package_A#1.0.0 not found.
How can I identified npm to its my own local package?
Notes:
We are a team, then I don't want to address package_A explicitly.
We are using nexus repository manager.
I don't want to publish my projects to http://registry.npmjs.org/.
I'm not 100% clear what you have tried. If you are going to use a custom module for another application you are developing, installing globally won't do the trick. You have to publish that module in npm.
Check this link for more info on publishing in npm
If you have completed the steps correctly, and still no good happens, please check your naming of the module in package.json file.
Instead of typing in the name and version number in package.json file and then npm install, try directly installing in the terminal with --save so that it will automatically be added to package.json file with correct spelling.

How to use locally updated npm package without publishing it to npm?

I'm using an npm package in my-project
and I have some updates I want to apply to that package:
I forked the original GitHub repo, cloned, and I'm making changes to the source on my local machine
my-project is still referencing the original npm package
I don't want to submit a pull request at this point, but I do want to start using the locally updated package in my-project
Is there an established process for doing this locally - using the updated source in my-project as an npm module?
Use npm link
You can use your local copy just like other packages.
npm link