Error installing Angular using npm due to require-from-string - node.js

How to resolve this error as I am not able to install Angular.
Please see the below exception:
C:\Users\absin\node>npm install -g #angular/cli
npm ERR! code ETARGET
npm ERR! notarget No matching version found for require-from-string#^1.1.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'cosmiconfig'
npm ERR! notarget
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\absin\AppData\Roaming\npm-cache\_logs\2018-01-06T19_07_00_000Z-debug.log
even after temporal solution:
npm install https://github.com/floatdrop/require-from-string/tarball/v1.1.0 --save
npm install
still getting this

as stated in the issue link:
temporal solution:
npm install https://github.com/floatdrop/require-from-string/tarball/v1.1.0 --save
npm install
UPDATE:
It appears they are working on it. The require-from-string page used to return a 404, but at least now it loads the correct page on NPM's website: https://www.npmjs.com/package/require-from-string
Still doesn't appear to be working through npm install yet.
UPDATE 2:
An official response from NPM: https://status.npmjs.org/incidents/41zfb8qpvrdj
UPDATE 3: issue seems to be resolved.

Even if https://status.npmjs.org/ says that it s all ok now,
the problem persist here

some problem with NPM registry some of the packages got deleted.
They are restoring it... it will be available shortly
Temp solution use the missing package from already running projects that or older projects.

I had the same issue. So when I used yarn it worked well and not having any problem to create new projects also.
yarn global add #angular/cli
again, when you create new app ng new newapp it will fail because at this moment npm is not able to find a package called require-from-string. But the you can run yarn to install all the packages. Yarn will ask which version of the require-from-string is needed. you can choose it.

npm is having issues. This should just work.

npm registry issue is now fixed according to https://status.npmjs.org/incidents/41zfb8qpvrdj
Solution
rm ./package-lock.json
git commit -am "Removed broken package-lock.json file."
git push heroku master

Related

Unable to resolve dependencies for Angular Universal

I need to use SSR for one of my existing angular project. For that, I have migrated one of my projects from v8 to v13.0.0, which itself took a lot of time.
HOwever, now that the app is running fine on v13.0.0, I tried adding SSR to it using
ng add #nguniversal/express-engine
This commands seems to add 13.0.1 of universal, but it keeps failing with errors similar to below one:
D:\my-app-universal>ng add #nguniversal/express-engine i Using package
manager: npm √ Found compatible package version:
#nguniversal/express-engine#13.0.1. √ Package information loaded.
The package #nguniversal/express-engine#13.0.1 will be installed and
executed. Would you like to proceed? Yes npm ERR! code ERESOLVE npm
ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR!
While resolving: my-app-universal#0.0.0 npm ERR! Found:
#angular/animations#13.0.3 npm ERR! node_modules/#angular/animations
npm ERR! #angular/animations#"~13.0.0" from the root project npm
ERR! npm ERR! Could not resolve dependency: npm ERR! peer
#angular/animations#"13.2.3" from #angular/platform-server#13.2.3 npm
ERR! node_modules/#angular/platform-server npm ERR! peer
#angular/platform-server#"^13.0.1" from
#nguniversal/express-engine#13.0.1 npm ERR!
node_modules/#nguniversal/express-engine npm ERR!
#nguniversal/express-engine#"13.0.1" from the root project npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this
command with --force, or --legacy-peer-deps npm ERR! to accept an
incorrect (and potentially broken) dependency resolution. npm ERR! npm
ERR! See
C:\Users\saurabhtiwari\AppData\Local\npm-cache\eresolve-report.txt for
a full report.
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\saurabhtiwari\AppData\Local\npm-cache_logs\2022-02-20T12_03_46_821Z-debug.log
× Package install failed, see above.
I have tried a lot to read through the errors and updating package.json to match the required version of peers but it just doesn't go away.
Is there a systematic way to resolve these errors.
Is there a particular version of universal that might go well with Angular 13.
Any suggestions are welcomed.
I followed #misha130's comments advice and fixed the version numbers. I didn't need to need to install with --legacy-peer-deps or --force.
The solution was to upgrade #angular/cli & #angular/core.
With a fresh install, my initial version was 13.0.4. You will need to upgrade them one at a time as the update command fails if there are staged and uncommitted changes in the repository.
ng update #angular/cli
git add . && git commit -m 'nguniversal fix 1 - update #angular/cli'
ng update #angular/core
git add . && git commit -m 'nguniversal fix 2 - update #angular/core'
ng add #nguniversal/express-engine
Thanks everyone for their inputs in the comment. I figured it out as below.
As suggested in comments, first I installed the universal package using --legacy --per --deps
npm install #nguniversal/express-engine --save --legacy-peer-deps
This installed the packages in the node_modules, although the required express-server related files were not added.
To add those files, I then ran:
ng add #nguniversal/express-engine
This creates the required file. It will also try to install the package again and will fail in doing so. Since the package have been installed already, I guess you can ignore its error.

What is the fastest way to update node and npm?

I have searched online numerous times and I cannot seem to get it working. Please tell me if my understanding is incorrect:
To update npm to the latest version:
npm install npm#latest -g
To update node to the latest version
Go to the official website and download it. However I would like to be able to update node and npm through the command line.
Anyway, running npm install npm#latest -g gives me:
npm ERR! code EEXIST
npm ERR! path D:\nodejs\npm.cmd
npm ERR! Refusing to delete D:\nodejs\npm.cmd: is outside D:\nodejs\node_modules\npm and not a link
npm ERR! File exists: D:\nodejs\npm.cmd
npm ERR! Move it away, and try again.
Could someone please tell me the solution of this, and also provide a way to update both node and npm through the command line easily?
EDIT: Sorry forgot to say, I am using windows
Delete the node_modules directory completely.
Run npm install again.
This should help you.

Error when installing http-server: No matching version found for ecstatic#^3.0.0

I'm new to front end development and now I have to maintain an AngularJS application. I'm trying to install http-server in order to test my app, but when I run the npm install http-server -g command, I get the following error:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for ecstatic#^3.0.0
npm ERR! notarget In most cases you ir one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'http-server'
npm ERR! notarget
I haven't found any solution. Have you guys seen this error before?
They've had a security issue with versions prior to 4 and have removed download links for them. You can find more details here: https://github.com/jfhbrook/node-ecstatic/issues/255 .
You'll either need a cached version from before or move to a newer version.
They are working on a fix.
This is a fork on NPM:
npm i http-server-legacy
or
yarn install http-server-legacy
Source: https://github.com/indexzero/http-server/issues/521#issuecomment-488843797
The maintainer has now patched the library, and the following versions should now be available:
2.2.2, 3.3.2, 4.1.2
Reference

Cannot Install Any Package NPM Node-JS

The problem I face is when I will install one of the packages NPM is always show
[............] /roolbackFailedOptional: verb npm-session ....
and the final show error like :
npm ERR! code e503
npm ERR! 503 Service Unavailable:
npm ERR! A complete log of this run can be found in:
npm ERR! C:Users\.......\AppData\Roaming\npm-cache\_logs\2018-08-08t08_09_25_773Z-debug.log
I have already found a solution from here. But it didn't worked.
The configuration NodeJS in my system :
and i use version for
NodeJS : 10.8.0
npm : 6.2.3
Please help me for fixed my problem...
not sure if it will fix your issue but i used
npm install --proxy proxy_address:port install package_name --save
when i had troubles with proxy, if this works, then you might have configured npm settings not the way you need to.

Node error npm ERR! cb() never called

When I am running the command npm install npm#latest -g
I am getting below error :-
npm WARN tar zlib error: unexpected end of file
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dk\AppData\Roaming\npm-cache\_logs\2018-04-10T03_25_52_880Z-debug.log
i googled it and tried so many things,nothing worked.
To anyone stumbling upon this question, if you are facing the same error message on npm install, then npm install --no-package-lock solved it for me.
As suggested in the referenced Github issue in Mohit Mutha's comment above, this is especially true if the command is ran in a CI/CD pipeline, or in my case, in Docker.
EDIT: Reason being is that the package-lock.json file already exists in your Docker image or CI pipeline
Full details
Our team encountered this error in our CI pipeline. However, the top answer of using --no-package-lock actually causes npm to also not use a present package-lock.json, which is definitely not the desired behavior for CI. Instead, using npm ci is now the recommended way to install in CI since it will use the existing package-lock (and nothing else).
Solved by running
sudo npm cache clean --force
and after that deleting package-lock.json and node_modules
and then performing
npm install
FYI I have gone through DOZENS of these responses for the exact same ask posted here again and again in SO. I think most of responses are valid. But in my case the actual issue was the CORPORATE PROXY not npm itself.
In my Dockerifle I had to explicitly add http-proxy and https-proxy to my npm config prior to running the npm install and it worked. FYI you need to tell npm config about your proxy or it wont download dependencies and this is what was throwing the cb() never called error - this works in both local (terminal) and docker containers.
...
RUN npm config set http-proxy http://mycompanyproxy.mycompany.com:8099
RUN npm config set https-proxy http://mycompanyproxy.mycompany.com:8099
RUN npm install
EXPOSE 3000
CMD ["node", "server"]

Resources