How to create offline private registry of verdaccio - node.js

I create private npm registry with verdaccio.
I want to able to run npm install --registry="http://localhost:4873" and get all dependencies from private registry.
I need to publish all packages from my project node_modules directory.
I had to run npm publish in each package in node_module directory.(I could't find any better way.)
more of them published successfully But in some case, I encountered with the error. for example in zone.js package:
npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! zone.js#0.8.29
prepublish: `tsc && gulp build` npm ERR! Exit status 2 npm ERR! npm
ERR! Failed at the zone.js#0.8.29 prepublish script. npm ERR! This is
probably not a problem with npm. There is likely additional logging
output above. npm WARN Local package.json exists, but node_modules
missing, did you mean to install?
or in acorn package:
acorn#5.7.3 build:main C:\Users\Admin\Desktop\test ng\ng-prj\node_modules\acorn
rollup -c rollup/config.main.js
'rollup' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! acorn#5.7.3 build:main: `rollup -c rollup/config.main.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the acorn#5.7.3 build:main script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
Is there a simple way of doing this?

here Verdaccio maintainer.
I want to able to run npm install --registry="http://localhost:4873" and get all dependencies from private registry.
What do you want is to have an offline registry with all your dependencies. Publish all node_modules is not practical and almost impossible.
more of them published successfully But in some case, I encountered with the error. for example in zone.js
That's the point, you would need to build each dependency, it just does not make sense. A regular project can easily have thousands of dependencies and sub dependencies. Not to mention you would lose the adventage of future dependencies updates.
So, what you need is cache properly all dependencies in your storage folder.
Run verdaccio $> verdaccio
Be sure you are online
Run npm install --registry="http://localhost:4873
When the finish to install, inspect your local cache, see here how to find it. You should be able to see all the resolved dependencies in the cache.
If you want a real offline experience, comment the proxy from the config file as follows
packages:
'#*/*':
access: $all
publish: $authenticated
# proxy: npmjs
'**':
access: $all
publish: $authenticated
# proxy: npmjs
If you comment out proxy Verdaccio won't ask for any update to the remotes, by default is npmjs, thus, no connection to external networks will be performed.
Restart Verdaccio
Repeat process as much time you need.
So, here, the advantages of this approach.
When yo back offline (you must comment out the proxy section again) you will allow Verdaccio to resolve wether you have new dependencies to be cached (in case you are using semver eg: lodash: ^1.5.6)
You will have a real installation experience, no fear to remove node_modules and clean the npm cache as well.
Storage is just a folder, so you can port it to another place (via USB or LAN)
Share cache with multiple projects and node package manager tools (yarn, npm or pnpn)
You don't have to publish each package in node_modules, thus see point 2).
I hope this helps you. Furthermore, there are other practices related with offline mode, but only with yarn.

We used Juan Picado's advice above. Here's what we did:
edit verdaccio's config file at /home/verdaccio/config.yaml
make sure that proxying is allowed
set the npm registry to point to your verdaccio instance
create a folder (any folder) on the system and run npm install commands to download packages
check the /home/verdaccio/storage/ directory. The downloaded packages plus their dependencies should now be in that directory.
edit verdaccio's config file, commenting out the two "proxy" lines so that proxying is turned off
restart verdaccio
At this point running npm install commands will only point to your verdaccio instance without going out to registry.npmjs.com and the packages in /home/verdaccio/storage will be your offline-available packages.

Related

How to solve the ESLint in React shows detected higher up in the tree?

> new-app#0.1.0 start C:\Users\sachin\reactjs\new-app
> react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"eslint": "^6.6.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of eslint was detected higher up in the tree:
C:\Users\sachin\node_modules\eslint (version: 7.10.0)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
6. Check if C:\Users\sachin\node_modules\eslint is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls eslint in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed eslint.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! new-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the new-app#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sachin\AppData\Roaming\npm-cache\_logs\2020-10-09T06_26_24_453Z-debug.log
If nothing works, try deleting node_modules in one directory back from your project.
Somehow I had node_modules in user/devdirectory, not in user/devdirectory/project

Facing these errors while doing "create-react-app"

The error I'm getting is like this:
vaibhav#Knighthood MINGW64 ~/Desktop/Coding NInja/tool (master)
$ npm start
> tool#0.1.0 start C:\Users\vaibhav\Desktop\Coding NInja\tool
> react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"webpack": "4.42.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:
C:\Users\vaibhav\node_modules\webpack (version: 4.44.1)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if C:\Users\vaibhav\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls webpack in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tool#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tool#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\vaibhav\AppData\Roaming\npm-cache\_logs\2020-09-01T10_23_38_476Z-debug.log
I have tried to fix the dependency tree by the suggested steps:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "webpack" from dependencies and/or devDependencies in the
package.json file in your project folder.
Run npm install or yarn, depending on the package manager you use.
But I'm still facing the same error.
My system configurations are:
Node -v : 12.18.3
npm -v : 6.14.8
OS : Windows 10 pro v2004 H1 x64

npm install is throwing errors

I was trying to make video conferencing using React, but after installing npm start isn't working. It is showing this in my terminal:
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"babel-eslint": "10.1.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-eslint was detected higher up in the tree:
C:\Users\Vatsal\node_modules\babel-eslint (version: 10.0.0)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "babel-eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if C:\Users\Vatsal\node_modules\babel-eslint is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls babel-eslint in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed babel-eslint.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! voom#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the voom#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Vatsal\AppData\Roaming\npm-cache\_logs\2020-07-29T14_00_29_296Z-debug.log
What I did was that I tried to install webpack globally. I also tried a few suggestions from the Internet and what was suggested in the terminal but nothing helped.
Just follow the exact instructions given in the error log:
To fix the dependency tree, try following the steps below in the exact
order:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "babel-eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
Run npm install or yarn, depending on the package manager you use.

npm install no longer possible after deleting module directory

So I wanted to help out, and forked a Node-RED module to make some small contribution, but then got lost messing around with how to get Node-RED to run my fork (for testing) rather than the packaged version. Then I learned about npm's ability to install from a Github URL, which is nice, but it wouldn't work because I had already installed the module. Then I found I couldn't uninstall it either
npm uninstall original-module
npm ERR! path /home/nodered/.node-red/node_modules/original-module/package.json
npm ERR! code ELOOP
npm ERR! errno -40
npm ERR! syscall open
npm ERR! ELOOP: too many symbolic links encountered, open '/home/nodered/.node-red/node_modules/original-module/package.json'
so in frustration I deleted the module's directory, only to find myself unable to move forwards, or backwards. npm install https://github.com/me/forkedmodule fails with
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master https://github.com/me/forkedmodule.git /root/.npm/_cacache/tmp/git-clone-d31dc53b
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-d31dc53b': Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-08-22T01_07_18_257Z-debug.log
and trying to install the original with npm install original-module fails with
npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules/original-module" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-08-22T01_09_56_127Z-debug.log
As you've probably guessed, I'm pretty new to Node.js, Node-RED and npm, but I haven't been able to help myself, so have to ask for help! It seems nonsensical to me that npm appears to be looking for a local copy of the package.json file belonging to the package I'm trying to install?
Edit: I should add that the above commands were all run as root.
Ok, found a solution, not sure if it's the best one though!
In the "project" directory (/home/nodered/.nodered in my case) there's a package-lock.json file which lists the packages used by the project. In there I found an entry for the original-module which I removed, after which I was able to install the package "normally" with npm install original-module.
Then to solve the permission issue when installing from a GitHub URL, I found I needed to impersonate the "nodered" user with su - nodered (it's a password-less user in my case). As "nodered" npm install https://github.com/me/forkedmodule succeeded without any error. A little curious since I was trying to do this as root before, and got a permission error, but there you go. I also took the opportunity to chown -R the project's node_modules directory to nodered:nodered as I could see that was a bit of mess.
In future, I will try to remember to su - to my nodered user first, and navigating to the project root (again, /home/nodered/.node-red in my case) before running npm install anything. Hopefully that will avoid any further issues. Oh and a note to anyone else who just wants to contrib some quick changes to a module hosted on GitHub: to "pull" in changes you simply run npm install https://github.com/me/forkedmodule again - npm doesn't appear to provide any dedicated "update" method.
I had the same issue, in my case the solution was to delete the package-lock.json, delete node_modules, then reinstall npm modules.

Polymer CLI - npm error code 1

I get this error when trying to install polymer CLI. I keep on getting this whenever i try to install it.
sudo npm install --unsafe-perm -g polymer-cli
Password:
npm WARN deprecated bower#1.8.0: ..psst! While Bower is maintained, we
recommend Yarn and Webpack for *new* front-end projects! Yarn's
advantage is security and reliability, and Webpack's is support for
both CommonJS and AMD projects. Currently there's no migration path but
we hope you'll help us figure out one.
npm WARN deprecated #types/assert#0.0.29: See
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12826
npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master
git://github.com/polymerelements/test-fixture.git
/Users/litsonthomas/.npm/_cacache/tmp/git-clone-eddd277b
npm ERR! /Users/litsonthomas/.npm/_cacache/tmp/git-clone-eddd277b/.git:
Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/litsonthomas/.npm/_logs/2017-06-22T17_39_34_600Z-
debug.log
I am new to polymer and I don't know where am getting wrong!
This seems to be a pertinent issue in this package (issues in the repository: #784 #800). You have to go to the npm site on Fixing npm Permissions and follow the steps there.
You may receive an EACCES error when you try to install a package globally. This indicates that you do not have permission to write to the directories that npm uses to store global packages and commands.
You can fix this problem using one of three options:
Change the permission to npm's default directory.
Change npm's default directory to another directory.
Install node with a package manager that takes care of this for you.
Whether you should follow one of the three options depends on each particular case. What I would recommend first is to try changing the npm default directory to some place with user read/write permissions. Then, you should start doing npm i -g without sudo.

Resources