Error when atempting to create an Angular project - node.js

I have both NodeJS 18.13.0 , npm 8.19.3 and AngularCLI 15.1.1 installed. But whenever I go to start a project with "ng new project" I get an error:
Installing packages (npm)...npm ERR! code FETCH_ERROR npm ERR! errno
FETCH_ERROR npm ERR! invalid json response body at
https://registry.npmjs.org/parse5-html-rewriting-stream reason:
Invalid response body while trying to fetch
https://registry.npmjs.org/parse5-html-rewriting-stream: Socket
timeout
npm ERR! A complete log of this run can be found in: npm ERR!
/home/shize/.npm/_logs/2023-01-18T01_10_18_697Z-debug-0.log ✖ Package
install failed, see above. The Schematic workflow failed. See above.
I've tried uninstalling angular and reinstalling it. I've also tried clearing cache or "npm verify cache". And finally, also tried "npm config set registry https://registry.npmjs.org".
Also, if this info is of any help, along my struggle two different folders were created when attempting to run "ng new project-name". These folders had a lock sign on them and I deleted them both with "rm -r". I really don't know what to do, the error has changed when trying different things. Like one being about a bad network or proxy error. Another error I came along when probing around for a solution was this:
npm WARN deprecated #npmcli/move-file#2.0.1: This functionality has
been moved to #npmcli/fs
But for now the error is the first one, so I'll take it from there. I've been stuck for hours, any help would be much appreciated.

Related

error npm ERR! code FETCH_ERROR npm ERR! errno FETCH_ERROR npm ERR! invalid json response body when installing reactjs

so im trying to learn ReactJS, but when i looked up to ReactJS docs, it says install with
npx create-react-app {project_name}
it also required nodejs & npm, i have installed node js latest version & npm. but when i run the command, it alwasy getting the same error, the error says
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/#types%2fsemver reason: Invalid response body while trying to fetch https://registry.npmjs.org/#types%2fsemver: EBUSY: resource busy or locked, rename 'C:\Users\AGUS\AppData\Local\npm-cache\_cacache\tmp\d5e89a99' -> 'C:\Users\AGUS\AppData\Local\npm-cache\_cacache\content-v2\sha512\5f\16\d22537befb8a38d3af73438bd2409a960900a502346287a0a0fa17784814bd2664f39eeb0107aa02ac292aeb51d7f52f4a90db5325d9b47bc8f5ce1538ca'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AGUS\AppData\Local\npm-cache\_logs\2022-11-02T08_20_55_473Z-debug-0.log
i have searched up this problem but its not solved, always error.
please help me solve this problem :(
i have tried uninstall & reinstall node, still not working,
i tried npm cache clean --force & npm cache verify still not working, thank you:)
Try :
npm cache verify
npx create-react-app {project_name}
I had the same error and these steps solved it.
√ Would you like to use src/ directory with this project? Yes
√ Would you like to use experimental app/ directory with this project? Yes
√ What import alias would you like configured? ... #/*
and also ensure that no background apps are running

I cannot install using NPM and I get an error

I have been trying to make a vite project as well as install some packages into some already existing projects in vscode yet when I do this I get the error of:
npm ERR! code EHOSTUNREACH
npm ERR! syscall connect
npm ERR! errno EHOSTUNREACH
npm ERR! request to https://registry.npmjs.org/create-vite failed, reason: connect EHOSTUNREACH 2606:4700::6810:1123:443
npm ERR! A complete log of this run can be found in:
npm ERR! /home/chimera/.npm/_logs/2022-11-12T23_58_02_327Z-debug-0.log
I have no idea how to fix this and it is quite annoying as I am not able to make or change any projects ): I also have tried searching this on StackOverflow and I get a similar error but none of the fixes I have tried seems to do anything. If you know how to solve this could you please explain why this happened ): I am also finding and I don't know if this is related to it or not that my terminals take forever to load when before when I opened one they took less than a second to do so? Also, I am using Ubuntu (The latest version) and previously just used the latest version of node and there is where I got the error, the moment I downgraded to node v16 it went away. The command I tried running was the command for creating a new react project and also to adding daisyui to a project I had.

attempting to deploy meteor application. Fails when running NPM INSTALL

Sorry for the following wall of text.
So I've been using someone else's meteor app. (they open sourced it) It's currently un-built and I've been running it on dev-mode. It's a lot slower than expected and users are having issues connecting to my local machine. So I'm attempting to deploy the app by following: https://guide.meteor.com/deployment.html#deploying.
So I've been getting errors when trying to run npm i. My dad recommended me to run npm cache verify and try again, then npm cache clean as a last resort. Neither worked and I've still am getting errors. Although as soon as I tried again after running npm cache verify the error amount skyrocketed. I unfortunately don't have the errors I got before I cleared my cache but I have the current logs here: https://pastebin.com/dAcRnE9v But here is a snapshot:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fibers#2.0.2 install: `node build.js || nodejs build.js`
npm ERR! Exit status 1
npm ERR! Failed at the fibers#2.0.2 install script.
I honestly don't have any idea what todo. I've never worked with meteor before, nor the fibers module that's failing. I don't even know if this is the right place I should be asking for help.
I once had fibers npm package in my package.json which caused a similar error. Once I removed it everything built just fine.
You can't change Meteor's version of node - for compatibility reasons it bundles node/npm with Meteor to protect you. Just prefix all your npm/node commands with meteor like this:
meteor npm install
It won't use the node version (13.x) that you have installed

NPM install failing with 502 error

This is a rather obscure issue. I have an Angular app that will be running through Codeship for CI. However, when it comes time to run npm install on the Codeship box, npm gives back
-npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
\npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
\npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm ERR! Linux 4.2.0-38-generic
npm ERR! argv "/home/rof/.nvm/versions/node/v4.1.1/bin/node" "/home/rof/.nvm/versions/node/v4.1.1/bin/npm" "install"
npm ERR! node v4.1.1
npm ERR! npm v2.14.4
npm ERR! fetch failed with status code 502
This was quite strange, since the npm install worked just fine on my box. My first instinct was that it had to be an issue with the NPM repository, so I grabbed the url for the package(https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz) and threw it into a new Chrome tab. Sure enough, the archive downloaded almost instantly. I was confused by this, so I tried the Codeship build again, but got the same results. I decided to SSH into the Codeship box to see if I could access it. I ran
curl https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
and as I expected I got the 502 error. However, when I ran the same command from the terminal on my machine, I got the same result, even though the npm install ran perfectly for me. I wasn't able to find anyone else having this type of an issue, and a 502 seems like a very rare code for the NPM registry to be returning. Any ideas?
This is a problem with the registry.npmjs.org in some regions.
Here is issue:
https://github.com/npm/npm/issues/13284
Try to keep one registry inside .npmrc file, only one of them works.
The order of registry also does matter. Also try to set:
npm config delete proxy
npm config delete https-proxy
to clean proxy inside terminal.
I'm seeing the same issue via npm install on Ubuntu 14 running on AWS
curl https://registry.npmjs.org/combine-lists/-/combine-lists-1.0.0.tgz
returns 502 Bad Gateway from the ubuntu server, but works fine from local client
There's an open issue at NPM for this:
https://github.com/npm/npm/issues/13284
NPM just acknowledged the issue and they are working on it. Your can track the status at below link.
http://status.npmjs.org
I got this error while publishing my package on npm. After banging my head against the wall for a few hours, I realized I was on mobile hotsopt. I switched to wifi and bang there was my package on npm!

Why am I getting Unexpected token '\u0000' when using npm install -g package

This is probably a Windows specific issue but I haven't found any information when googling this issue. I had been using ionic framework which relies on Cordova (or Phonegap). However, the problem is not specific to any of these packages. I see this error quite often. So, the error is when I run a command such as the following:
npm install -g cordova
However, I could substitute various other packages and get the same error. I'll paste the snippet (very brief) below of the error message. What is strange is that I had an ionic project working in that directory earlier. Then today it told me that ionic could not be found. My hunch is that this is a different issue than the main issue I am describing here.
I installed git bash so I do have a linux-like environment that I could try. I would just select Git Bash for a bash window with various bash commands. If there is an easier way to fix this for Windows users, please let me know. I have seen courses on Pluralsight where the instructors seem to be happily using npm with no problems. Also, when I use yeoman, I also at some point, in many cases, get the same error.
The error is
npm ERR! Failed to parse json
npm Unexpected token '\u0000' at 1:1
npm ERR!
npm ERR! ^
npm ERR! File: c:\Users\Bruce\AppData\Roaming\npm-cache\amdefine\1.0.0\package\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm
npm ERR! Tell the package author to fix their package.json file. JSON.parse.
Thanks in advance for any help/advice,
Bruce
Via this question on SO it could be that you just have to do:
npm cache clean.
But, also try the other methods suggested there like adding the registry option:
npm install <packagename> --registry http://registry.npmjs.org/.
Or, if you've been mingling with the package.json file by yourself, check if it's valid.

Resources