An unhandled exception occurred: Could not find module "#angular-devkit/build-angular" - javascript

When running the terminal commands ng server or ng serve I'm getting this issue:
An unhandled exception occurred: Could not find module "#angular-devkit/build-angular"

Check in your package.json to see if you have this package in your devDependencies section or not
"devDependencies": {
"#angular-devkit/build-angular": "~0.803.18"
}
If exist try to
delete package-lock.json or yarn-lock.json
run
npm cache clean --force
then run
npm i

Install #angular-devkit/build-angular as dev dependency.
npm install --save-dev #angular-devkit/build-angular
or,
yarn add #angular-devkit/build-angular --dev

This error (Unhandled exception for a module) occurs when node_modules folder does not exist inside the project, or when the folder exists, but does not contain all the dependencies downloaded.
$ npm install command will download all the dependencies into the node_modules folder of the proejct.
npm install is automatically triggered in the background by the 'ng new', at the time of creation of the angular project.
The other angular commands like 'ng build' or 'ng serve' commands assume that 'ng new' had completed successfully.
If, for some reason, the npm install failed at the time of creation, or if the node_modules folder got deleted after the project was created, then the other angular commands (ng serve, ng build, ...) will generate this 'Unhandled Exception'.
Manually executing the npm install command inside the project will download the dependencies and fix the issue.

try this
npm install --save-dev #angular-devkit/build-angular

Make sure "#angular-devkit/build-angular": "~0.10.0" is available in devDependencies of package.json before running npm install in your angular root directory.

Related

"npm install" not installing any library. How to resolve this issue?

I am using Node version 14.15.5 and npm version 6.14.11. Also, I am working on VS Code.
I have tried to install two packages by these commands:
npm install express
npm install lodash
In the end, I am not getting any of them successfully.
I received this message:
36 packages are looking for funding
run `npm fund` for details.
How to resolve this issue?
enter image description here
The reason is described here:
Before installing a package into the local folder, NPM tries to find the root of your package. To do this it walks from your current directory (C:\Users\JD Mughal\Desktop\Web\Node\test-calculator) up the hierarchy until it finds a package.json file.
Only if no package.json file is found will NPM install the new package in the current directory (respectively in a node_modules\package_name subdirectory).
In your case however NPM finds a package.json file C:\Users\JD Mughal\package.json and installs the new package there.
To resolve the use you must execute npm init in your local directory.

module npm file doesn't appear to me

I am trying to follow with pluralsight tutorial and he wrote npm install on the terminal, then a file called npm module is installed on the folder he specified. when I try to install npm this appears to me in the terminal, and the directory which Im trying to install npm on it contains only one document called package-lock.json enter image description here
npm install uses the package.json to install the necessary packages
I can see when you ls, there's no package.json in the directory, just the package-lock which is created where ever you run npm install
Make sure you run the npm install from the same directory the package.json in contained in
the problem is solved, I think that I download the web-dev-starter folder twice by mistake.

How do I remove yarn from angular cli. I want to use npm to install packages

Installing packages for tooling via yarn.
An unhandled exception occurred: 'yarn' is not recognized as an internal or external command,
operable program or batch file.
Package install failed, see above.
See "C:\Users\hp\AppData\Local\Temp\ng-TAwQZJ\angular-errors.log" for further details.
This is the error in my terminal everytime I try to install any package.
I have tried "npm uninstall -g yarn" nothing happens. I tried in control panel to find any yarn package but nothing.
How can we do this and install packages via npm?
try either of
ng config --global cli.packageManager npm
or
ng set --global packageManager=npm
Also, Yarn is faster and better as per some blogs,
So you can keep yarn as default package manager and install it
https://classic.yarnpkg.com/en/docs/install/

npm related tasks are throwing errors during installations

I've been having this problem recently that nothing related to npm is working for me except npm start.
npm install is giving this error:
$ npm install #material-ui/core
npm ERR! Object for dependency "#babel/generator" is empty.
npm ERR! Something went wrong. Regenerate the package-lock.json with "npm install".
npm ERR! If using a shrinkwrap, regenerate with "npm shrinkwrap".
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Parth\AppData\Roaming\npm-cache\_logs\2020-08-20T13_52_13_701Z-debug.log
npx create-react-app ./ is giving this error:
npx create-react-app ./
npx: installed 98 in 10.023s
Creating a new React app in G:\hel.
Installing packages. This might take a couple of minutes. Installing
react, react-dom, and react-scripts with cra-template...
yarn add v1.22.4 [1/4] Resolving packages... [2/4] Fetching
packages... error An unexpected error occurred: "UNKNOWN: unknown
error, unlink
'C:\\Users\\Parth\\AppData\\Local\\Yarn\\Cache\\v6\\npm-core-js-pure-3.6.4-4bf1ba866e25814f149d4e9aaa08c36173506e3a-integrity\\node_modules\\core-js-pure\\features\\object\\is-frozen.js'".
info If you think this is a bug, please open a bug report with the
information provided in "G:\\hel\\yarn-error.log". info Visit
https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Aborting installation. yarnpkg add --exact react react-dom
react-scripts cra-template --cwd G:\hel has failed.
Deleting generated file... package.json Deleting generated file...
yarn.lock Done.
EDIT: So I tried using Yarn for my installs but got this error:
$ yarn add #material-ui/core
yarn add v1.22.4
warning package-lock.json found. Your project contains lock files generated by
tools other than Yarn. It is advised not to mix package managers in order to
avoid resolution inconsistencies caused by unsynchronized lock files. To clear
this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "UNKNOWN: unknown error, unlink
'C:\\Users\\Parth\\AppData\\Local\\Yarn\\Cache\\v6\\npm-core-js-pure-3.6.4-4bf1ba866e25814f149d4e9aaa08c36173506e3a-integrity\\node_modules\\core-js-pure\\features\\object\\is-frozen.js'".
info If you think this is a bug, please open a bug report with the information
provided in "F:\\Parth\\covid-19-tracker\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
How do I fix this?
Edit: My version of npm is 6.14.8
First of all you need to make sure that your node and npm versions are up to date. if not please upgrade your node and npm packages to latest versions.
nvm install 12.18.3 // update node version through node version manager
npm install npm // update your npm version to latest
Delete your node_modules folder, package-lock.json and yarn file (if you have).
Force clean the entire NPM cache by using following comand.
npm cache clean --force
Re-Install all the dependencies.
npm install
If above step didn't resolve your problem, try to uninstall yarn globally by delete the Yarn folder from global folder and then run.
npm uninstall -g yarn

npm install couldnt install angularjs libraries

I have installed mean.io and ran sudo npm install. Actually following commands in sequence
sudo npm install -g meanio
mean init yourNewApp
cd yourNewApp
sudo npm install -g bower
sudo npm install
It is supposed to download and install angularjs libraries into public/system/lib. After doing the above steps public /system/lib is not created due to which when I start the application I get the error
events.js:72
throw er; // Unhandled 'error' event
^
Error: ENOENT, open '/home/santhosh/dev/scaleqa/mean_tut/old mean/temp/myapp/public/system/lib/bootstrap/dist/css/bootstrap.css'
[nodemon] app crashed - waiting for file changes before starting...
Is it something to do with certain npm/angularjs server being down. I have faced this problem earlier also but got fixed on 2nd try and I didn't bother to do more research. This became a big issue when I try to pull my repo into cloud and start the application. public/system/lib is added in .gitignore by default and is expected to be created during npm install.
I get following warnings with sudo npm install
npm WARN package.json mean-connect-mongo#0.4.3 No repository field.
npm WARN cannot run in wd mean#0.3.3 node node_modules/bower/bin/bower install (wd=/home/santhosh/dev/scaleqa/mean_tut/old mean/temp/myapp)
this is link to package.json
The problem maybe related to running npm install as sudo, which can cause problems. As mentioned in another stack overflow question, this can be worked around in a couple ways. But because it looks like this is being run from your home directory, you really shouldn't need to run npm install as root.
Try to issue the same commands, but the last without sudo:
sudo npm install -g meanio
mean init yourNewApp
cd yourNewApp
sudo npm install -g bower
npm install
Note that the reason you may need to run npm install -g <package> using sudo is because by default npm uses /usr/local for global installs, which can be a restricted directory. However, when you install a package locally (without the -g flag) you should not need to run as root.

Categories

Resources