troubleshoot angular project errors - node.js

I was provided an angular project with a set of existing errors and a list of enhancements to work on. When I downloaded the same and tried running "npm install" on the project, it failed saying "Operation not permitted by operating system". I have tried all the solutions suggested online including:
npm cache clean
npm cache clean --force
deleting the node_modules folder
Running npm cache clean over and over again
Trying different versions of Node along with npm v5+
Running all the commands and opening IDE in "Run as Administrator" mode
Ran all the commands from command prompt as well
Ran all the commands from command prompt opened in "Run as Administrator" mode
Deleted the package-lock.json file and then ran "npm install"
Deleted the package-lock.json file and then ran "npm install --no-optional"
In between all the above steps tried my own recipes as well.
If someone could help me figure out what the issue is?
I found a thread on Github discussing the error. The solutions described do not work for me.
https://github.com/google/material-design-icons/issues/853

Finally, The below steps helped me resolve the issue.
Installed material-design-icons globally using npm install material-design-icons -g
Next, removed the node_modules directory from the project and ran npm install.
This worked for me but not in time to submit before deadline. The project compiled and ran successfully using npm start post the above steps.

Related

react app is successfully created, but npm start throws an error

I installed the latest nodejs 19.2.0 on my windows 11 OS rather than the recommended for most users 18.12.1
npx create-react-app my-first-app works just fine, it creates all the files and folders without any errors, shows happy hacking message as well, recommends to use npm start command. I go inside my-first-app folder, go npm start and I get a module not found error...like this picture
Error Message Screenshot
In youtube tutorials, there is no any error in their pc. npm start runs just as easily as npx create-react-app <anyappname>.
F:\Tutorial & Practice\Frontend development\React Projects\my-first-app. With this path to your project, I can see there is an & symbol in the Tutorial & Practice directory. Sometimes that might cause error. Try renaming the directory without any symbols or even spaces, just to be sure. Then run npm start. And if that still doesn't work delete the node_modules folder and then npm install again and see if that works.
Try this first:
npm install react-scripts
If the error wasn't solved, then try this:
rm -rf node_modules
npm cache clean -f
npm install
npm install react-scripts

Vite - How to npm run dev when I have deleted both package-lock and package.jason folders?

Im following along a tutorial on YT on how to code and deploy a react website. I created my project using Vite. Everything was reflecting fine on my browser window until I closed the terminal and now my browser returned "This page can't be reached". So I tried running npm run dev one more time and I get a bunch of errors. Looked online for an answer and ended up deleting both the package-lock.json and package.json folders. Now when I run npm install I only get a rather almost empty package-lock.json folder. Is there a way to undo this? I feel like I messed around too much with the terminal. How can I go back to running npm run dev effectively?
You need to install the packages again,
You need to initialize the package again.
I'd suggest going through the source code in order to find out the name of the packages.
npm init
then all you need to do is
npm i pkg1 pkg2 pkg3

Unable to find expo in this project - have you run yarn / npm install yet? Npm has been installed, expo directory exists

My Expo project is pretty much 9999999% errors thus far, and it finally reached its climax when it decided to throw an error I've never heard of at me:
module not found: can't resolve '../utilities/platform'
I've never seen this, and I was explicitly working in an isolated styling file when it occurred. I deleted the file and the error persisted. Seeing that it was in node_modules, I figured that deleting node_modules would be helpful. It wasn't. I deleted the node_modules and tried to run npm i --save afterwards but it kept erroring out. I restarted my computer, deleted the new node_modules, and tried to run npm i --save yet again. This time I was greeted with this:
read-shrinkwrap This version of npm is compatible with lockfileVersion#1, but package-lock.json
was generated for lockfileVersion#2. I'll try to do my best with it!
npm ERR! Maximum call stack size exceeded
Now, I have a half(ish) completed node_modules, and whenever I try to run expo start, which I have about 700000000 times before this, it tells me this...
Unable to find expo in this project - have you run yarn / npm install yet?
Which, yes stupid I have my expo set up, and yes AGAIN, I just ran npm install about twenty-two times. So I have absolutely no idea what happened, why it happened, or how to fix whatever happened. If you can help me I will award you my first born but fair warning that might take another 20 years
Try to remove all react-native data folders from "%appdata%\Temp" and execute following commands:
cd android (if any)
gradlew clean
cd.. and remove the node_modules folder
npm cache clean --force
npm install
npm start -- --reset-cache

Npm start and Build is no longer working on my Windows

I have been using npm for months to build projects and it's suddenly stopped working 5 days ago on all my React projects.
Now, whenever I try to run npm start I get an error saying:
project name #0.1.0 start
react-scripts start
The system cannot find the path specified.
So, first I tried npm install again and then start but it didn't work so I tried npm cache clean and got an error saying:
npm ERR! As of npm#5, the npm cache self-heals from corruption issues...
and then the terminal told me to try npm cache clean --force. Then I got another error saying:
npm WARN using --force Recommended protections disabled.
I have also tried running npm cache verify and it didn't work. I even went as far as downloading and installing the latest version of node and still nothing.
and it's not just that i also tried doing "npm run build" on another app in another directory and it showed this
"amazon-clone#0.1.0 build
react-scripts build
The system cannot find the path specified."
I checked and I'm using NPM version 7.9.0
please I'm stuck and I don't know what to do about
I too faced this problem and I resolved this by,
Create a .env file in react project root directory.
Add this line SKIP_PREFLIGHT_CHECK=true.
It took a while but i found that running
"npm config set script-shell bash" on git bash
fix the issue but only on git bash

Why do Node modules go into .staging folder?

I have an Electron app that I'm trying to install node modules for. When I run npm install, it creates the node_modules folder but all the modules go into a subfolder called .staging. Each module also has -xxxxx appended to it, where the x's are some random alphanumerics.
Other Electron apps I've created have never done this. All the node modules sit in the root of node_modules and don't have -xxxxx appended.
Any idea why this is happening?
I was also facing the same issue, I tried the steps below:
Delete package-lock.json
Delete Node Modules folder
Try installing it using below command (should be in open network)
npm install
Note: - ".staging" means, those dependencies are getting downloaded so for the temporary basis it keeps all those dependencies under ".staging" folder. Once all gets downloaded properly then it will showcase them under node_modules only.
I hope this will work.
This only happens temporarily until the modules are downloaded and installed. Node seems to do this so it can place together common submodules from all the modules you are installing so it can better structure the node modules folder(mainly for windows users).
If this is happening after an npm install finishes it is likely that there is something wrong with your node installation or something in the install failed.
If you're automatically installing node_modules using CI/CD you should check out npm ci. Also check out this Stackoverflow question.
npm ci
The documentation points out the differences between npm install and npm ci.
The project must have an existing package-lock.json or npm-shrinkwrap.json
If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.
If a node_modules is already present, it will be automatically removed before npm ci begins its install. This is nice, because it prevents having to do something like rm -rf node_modules.
It will never write to package.json or any of the package-locks: installs are essentially frozen.
.staging is a temporary npm folder, where the modules are temporarily saved while they are being downloaded, if the package.json downloads are still not completed, the created folder remains, until the installation is complete.
The problem may be lack of space on your hard drive.
I was having 2 versions of node installed on my system.
nodejs v4.2 and node v8.6
I thought this could be conflicting, so I deleted nodejs v4.2 with following commands.
sudo apt-get remove nodejs
and linked the path with
sudo ln -s /usr/bin/node /usr/bin/nodejs
Again I ran npm install and it got fixed
Delete package.lock.json
Delete node_modules
run npm update
This worked for me
I moved the project from C drive to other drive and ran the following commands
take a backup of older node modules if you are running this and existing project
npm cache clean --force
npm update
I faced similar issue and tried the above answers but it did'nt worked for me;
I followed below steps to resolve this issue-
1.npm audit
By running npm audit I got list of pending packages to install-
2.npm i packagename
After installing one or two package one by one from list, I used
3.npm install
At this time the installation went smooth without any lag or hangup. Hope this help who is facing similar issue :).
Sometimes the cache is corrupt and also unremovable.
This fixed the issue I was experiencing.
If you are using nvm
Get the current node version node --version
nvm uninstall (that version)
nvm install (that version)
nvm use
npm install
If you have a windows machine where you do not posses Admin rights to it.
Try deleting node_modules and install using 'npm install' from command line as
'ADMINISTRATOR'
It works!
Anyways, it comes down to an open network thing ;)

Resources