Grunt test on cloned repository fail - node.js

I created a webapp at work by using Yeoman's generator-webapp, did some work, and then checked it in to git. I didn't change anything in the .gitignore, so none of the modules/bower components were in the git.
So when I got home, I tried to work on it a bit more. So I started by cloning the repository. Then in nodejs, I ran the following to install the project's dependencies:
npm install && bower install
I then ran grunt test to make sure it works, but what I got was an ERROR.
Warning: PhantomJS unable to load "http[colon]//0.0.0.0:9001/index.html" URI. Unable to continue.
But if I ran yo webapp again and overwrite everything except for existing files in /app/ to keep my work intact, the generator would install a bunch of things (which I don't know what they are), and then grunt test would work.
As I don't want to ask my colleagues who would be cloning this project to run the risk of overwriting the files in /app/, I'd rather they install the missing components. Can anyone tell me what to do to get this working?
Many thanks.
John.

Someone, somewhere told me to run the following command
npm install && bower install to install all the dependencies and it started working.

Related

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

npm error: Cannot find module '.../immer.js' when building a create react app through CLI

I am trying to build a website using create react app and bootstrap. We are hosting the site via GH-pages and our repository is here. I have not had issues deploying the site locally until today, but have not yet been able to solve the problem after many hours.
I will go through the steps I performed to get me to where I am at.
Cloned repository through GH Desktop
Opened terminal and input brew reinstall node
Moved to project directory and input npm install react-bootstrap bootstrap#4.6.0 and npm install
Finally input npm start
I was met by this:
When I look in '.../node_modules/immer/dist', I see it contains 'immer.d.ts'. Further, when I look in '.../node_modules/react-dev-utils', 'immer.js' is present. I do not know much about Typescript, but the "main" entry looks like it is present, and the files are all present:
I have uninstalled and reinstalled the package manager, repository all day. I even reset my terminal and text editor to test it on a fresh reboot. I have gone through many StackOverflow questions and done things such as removing only the node_modules and package_lock.json files then inputting npm install, with no success.
Does anyone know what is missing? What should I do?
UPDATE
The problem with the 'immer' file was fixed by following the steps provided in the response: clearing the cache, updating the repository, getting a fresh clone, removing the damaged files, and installing npm.
After following these steps, the terminal returned this issue. I have tried troubleshooting this one as well, but feel like I am going in circles. Any directed advice helps.
First and foremost: exclude your node_modules file from git index. There is an entry in .gitignore to exclude it but it looks like you've included node_modules in index before adding that entry. Now you need to run a bit more sophisticated algorithm to get rid of it.
Quick troubleshooting for your problem (a bit redundant to my taste but just to make sure you didn't miss anything important):
# force cleaning npm cache. you may have a broken package there
npm cache clean --force
# clone repository into newly created directory (guaranteed to be clean)
git clone https://github.com/cameron-keene/ACE_Website somedir
# switch to the new directory
cd somedir
# remove broken node_modules
rm -rf node_modules
# remove (possibly) broken package-lock
rm package-lock.json
# fresh dependency install
npm install
Right now it looks like your immer dependency stored in node_modules is broken. As it has a lot of missing files and dist/immer.js is one of. That's why you're getting your error.
This problem was solved with
npm install --legacy-peer-deps
Shoutout to this Stack Overflow answer

Semantic-ui trying to run gulp build but none of its dependencies are installed

I'm trying to install them all manually one at a time, so hopefully it works, but why is this necessary? the documentation asks me to run the command from within the semantic folder where npm install does nothing to rectify it, and gulp build fails because none of the dependencies are there? Scratching my head.
Nevermind, I reinstalled in a different folder, and tried again and it worked properly without intervention this time. Not sure what went wrong.

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 ;)

Installing and Using Node JS in My Project

Im very very new in NodeJS
I want to ask about installing and using it in my Project..
I've installed nodejs in my Windows, but I have no idea how to make it works in my Cordova/Phonegap Project. I want to install this module in my project node-gcm. it said I just have to execute npm install node-gcm --save but I dont know where should I execute that command so I tried executed it on my project root (/www). After that I tried the example application code to use it but It said that require is not defined. Can anyone tell me how to fix this?
You need to learn nodejs properly to use in your project. I would recommend the below site could be a good starting point for you which covers all the basics.
http://www.tutorialspoint.com/nodejs/
You are getting that error because, when you look at the package.json file of the node-gcm package, you will notice the dependencies mentioned as,
If you are a windows user, you need to get into your node_modules directory by giving cd node_modules command in your command line and then just issue this command npm install which will install all the required packages.
Hope this helps!.

Resources