I am taking an online coding class and I just started learning my way through Terminal. I was trying to run a npm test but could not figure out why I was getting an error. I looked up different ways to solve it but it only made things worse as I have changed the package.json file into package-lock.json somehow.
Is there a way I could undo this?
Below is the command that I typed:
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
npm install -g #angular/cli#latest
It would be greatly appreciated if someone could help me.
Thanks!
Not sure what you are trying to achieve here.
Each part of your command does the following
npm uninstall -g angular-cli
will uninstall the angular command line interface globally (this is what -g does).
npm uninstall --save-dev angular-cli
will uninstall the angular command line interface, and remove from devdependencies within your package.json file.
these two above are the same command apart from the extra arguments.
And then after that you are globally reinstalling the latest angular cli ??
Futhermore for future reference, in order to chain commands you need to add '&&' between the npm commands for one line
Hope that clears something up
Related
I am receiving an error while trying to use Typescript with my existing expo project.
While following the docs, I created a tsconfig.json file in the project root.
When running expo start, I am prompted to install the typescript dependencies. However, after these are successfully installed (tick message appears in console: √ Installed typescript#~4.3.5, #types/react#~17.0.21, #types/react-native#~0.67.6), I receive the following error:
It looks like you're trying to use TypeScript but don't have the required dependencies installed.
Please install #types/react by running:
yarn add --dev #types/react#~17.0.21
If you're not using TypeScript, please remove the TypeScript files from your project and delete the tsconfig.json.
error Command failed with exit code 1.
After following the instructions and running the yarn add .... command, I keep seeing the same error message.
I have tried deleting the node_modules folder and package-lock.json file to no avail. I have also tried following this answer.
Any assistance would be appreciated, thank you.
Seems to be a bug. It works if I install #types/react on the specific version that Expo requests (17.0.21).
yarn add --dev #types/react#17.0.21
Just re-install expo-cli npm install -g expo-cli.
I don't know which of the following worked, but I ran the following commands and the problem went away.
sudo npm install -g expo-cli
sudo npm install -g #types/react
sudo npm install -g #types/react-native
sudo npm install -g typescript
yarn add expo-cli
solved for me.
I had the same issue. I resolved it by :
1- delete the node_modules.
2- update expo to the latest version using npm i -g expo-cli
hope this will help someone
if you installed #types/react remove that from your dev dependencies
I've been developing a later-to-be-release Open Source project with Node as a CLI tool. The CLI itself works great I only need to test if it works while on another project, so for that I installed the projects globally npm install -g without errors, but for the life of me I can't use the CLI.
I get the following error:
The odd thing is that the directory and file does exist in the global npm folder:
This is the project's package.json:
Am I not understanding how making a npm/node CLI works? What I'm missing?
EDIT 1:
This is my index.js file:
And this is the commander.js file:
EDIT 2:
After creating a test project as #AngYC suggested I could use the test cli successfully, while inspecting the difference I found this. Inside C:\Users\Ivan\AppData\Roaming\npm the .cmd of both projects are quite different:
EDIT 3 (Solution):
After fiddling around I found out that the file that really needed the shebang (#!/usr/bin/env node) was only index.js file and not the commander.js one. Removing the shebang in that file solved the problem
You may want to try to link your local package to your global executable list.
https://docs.npmjs.com/cli/link
All you have to do is run npm link in the folder you got your tool and it should make the command available globally.
Try to uninstall cli run npm rm -g cli or sudo npm rm -g cli. Then you run: npm install cli -g
If the problem persist, you might want to remove you npm package globally, probably there might be some conflicting things running.
Type this: %appdata% (either in explorer, run prompt, or start menu).
You can simply remove all globally installed npm packages by deleting the contents of:
C:\Users\username\AppData\Roaming\npm
Then you might also want to clear all the your cache run npm cache clear or npm cache clear --force as the case might be.
Then you reinstall all your packages that were install globally again.
If problem still persist, check this:
When you run npm root -g, it yields C:\Users\<username>\AppData\Roaming\npm\node_modules, or even, you should check your path maybe the executable binaries and .cmd files end up in C:\Users\<username>\AppData\Roaming\npm instead of C:\Users\<username>\AppData\Roaming\npm\node_modules, you will need to add that path to the PATH env. variable.
I hope this resolves your issue.
I'm working on an ancient react native project, it was absolutely working, then when I wanted to continue working on it, I had this problem,
This is the package.json file.
I ve tried this solution here, deleting the package-lock.json file and re executing
npm install
but it doesn't work for me.
I've tried to uninstall react-native-cli gloabally with
sudo npm uninstall -g react-native-cli
and than install it globally
sudo npm insatll -g react-native-cli
and now it works perfectly :)
I installed lodash and several other libraries this way:
npm install grunt-contrib-jshint --save-dev
npm install grunt-contrib-testem --save-dev
npm install sinon --save-dev
npm install -g phantomjs
npm install lodash --save
npm install jquery --save
When I run testem using grunt (or directly), I found the following problem
ReferenceError: _ is not defined
Digging into the issue, I found the issue in the mode following line
module.exports = require('./lodash');
(I have to point that the ./ is added by the installer. I even tried to remove it, but the error persist)
This is located on index.js, inside the node_modules/lodash folder
I think this is an issue of installation, but no matter what I do, it continue failing. I update npm, I remove node_modules and install all over again, but this continue happens.
Any advice or clue will be greatly appreciate
You don't need to pass the relative path of modules that are inside the node_modules directory, just passing the module name will do the trick:
require('lodash');
Now node.js will automatically look inside the node_modules directory for you, simple as that <3.
I can not run the Angular 2 project.
What I tried:
- running the project by using npm install and npm start | does not work
- I cloned quickstart from the github and replaced with my src folder and I still get the "can not find module in #angular/core"
Here is the full console output: https://www.dropbox.com/s/5plmqrjd6ge0lta/error.txt?dl=0
Many people will come here. I have had the same problem. Do not panic. You are probaly following the tutorial of tutorialspoint.
Just install the core again using NPM
npm install #angular/core
There was/is a bug in certain versions of npm that causes installed modules to disappear when using npm install someModule ... or npm install someModule --save-dev
This was apparently an issue if the module being installed was from a GitHub repo and lacked a specific commit hash to reference for the installation. Although the issue was marked "closed" and the repo archived several months ago at v5.6.0, I ran into the problem today w/the latest npm 6.4.0
In my case, doing npm install rxjs completely removed the #angular/core module, along with my #ionic-native plugins, and anything else I'd installed individually (and then it failed to actually/properly install rxjs anyway!!)
Tip: copy your existing npm modules folder as a backup before starting updates or removing it entirely & trying to npm install.
You can manually install to your project via npm install #angular/core, but depending on the npm version (or the angle of the moon at that precise moment, who knows) be aware that you might wind up with other missing dependencies.
Also try npm install #angular/core && npm install ... Apparently the additional npm install helps replace the randomly deleted/missing modules in some cases.