Angular "npm i" Unsupported engine error message - node.js

I am trying to install all the dependencies of my angular application.
Now once I enter npm i to install all the dependencies I am receiving this error message.
Initially, I thought this is an issue with Installing Angular CLI globally using npm, so I run the
npm install -g #angular/cli
and I received this message -
Now anyone has any idea what is wrong with the angular CLI message and also what do I need to do to successfully install the npm i to my angular application successfully?

Angular requires an active LTS or maintenance LTS version of Node.js:
https://angular.io/guide/setup-local#prerequisites.
So install LTS releases of Node.js: https://nodejs.org/en/about/releases/

yes you have the wrong version of #nguniversal and its not compatible with the current version of angular you have which looks to be 12.x.
so you have to type for good measure:
if any have an error its because one of the packages are not there and that's okay with the next step
npm uninstall #nguniversal/common
npm uninstall #nguniversal/builders
npm uninstall #nguniversal/express-engine
now type
ng add #nguniversal/express-engine
that's it it will add itself - there is still a lot of work post this though so please follow these instructions carefully.
https://angular.io/guide/universal

Related

Strapi V4 Error: Can't resolve '#strapi/design-system/themes'

I'm trying to run the new Strapi version 4 application. But it returns this error.
Is there any bug in new strapi v4? or I'm doing wrong anything?
I'm using strapi official guide to start a new project
installation command npx create-strapi-app#latest molla-admin.
NodeJS v16
Windows 11
Error
ModuleNotFoundError: Module not found: Error: Can't resolve '#strapi/design-system/themes' in 'C:\Users\Admin\Desktop\molla-admin\.cache\admin\src'
at C:\Users\Admin\Desktop\molla-<anonymous>:10:1)
You might be thinking #strapi/design-system package is missing right? After that, I also tried to install both #strapi/design-system and #strapi/design-system/themes npm package
Still, it doesn't work. It returns a new error
ModuleNotFoundError: Module not found: Error: Can't resolve '#strapi/icons/CarretDown' in 'C:\Users\Admin\Documents\testing\strapi-v4-app\node_modules\#strapi\helper-plugin\build'
Should I go on for the next missing Module?
For me the issue was solved by installing #strapi/design-system (Node: v14.15.5, npm: 8.1.3)
npm install #strapi/design-system
Node version : 14.18.1
Npm version : 6.14.15
OS : Ubuntu 20.04.3 LTS
Steps I followed:
(I read somewhere that the latest version of node isnt working and
someone mentioned using the 14.18.1 version)
Downgraded NPM to use the 14.18.1 version and not the latest.
npm run build on the strapi project. This gave an error that its
missing #strapi/design-system.
npm install #strapi/design-system, you get another error that its missing #strapi/icons
npm install #strapi/icons . After this step there was an error relating to JSX scritps something to do with reactjs. So, in the next step , I updated Reactjs
npm install --save react#latest
npm run build again and this time SUCCESS!!
The strapi team should mention the issues on their homepage rather that making new users go through hoops to get it working. They need to make it clear that you can run into issues when using certain version of Node etc. As someone mentioned that they are aware of the issue yet no information in the homepage where new users visit to try it out. It should've been placed as a BANNER at the top in BOLD TEXT.
It's a known bug and they are working on a fix.
You have to use yarn in the mean time.
I can confirm that this bug is related to using Node v16. To get around the bug, I first ran:
nvm use 14.18.1
Afterwards, running the following resulted in successful compilation:
npm run build -- --clean
No need to attempt installation of #strapi/design-system.
I got this error because I was using Node v16. There was a message somewhere in my troubleshooting that you have to use A Node version >=10.X.X.X and <=14.X.X.X
I used NVM(Node Version Manager) to switch to 14.17.6 and it works
following solution worked for me:
yarn add #strapi/design-system
yarn add #strapi/icons
work on windows and ubuntu
node v14.15.0
yarn 1.22.17
npm 6.14.8
npm install #strapi/design-system
solution worked for me.
node 16.13.1
npm 8.1.4
macOS 12.0.1 on M1Max

Unexpected end of JSON input error when creating new project

Each time I use angular/cli to create a new project by launching the following command
ng new Project-Name
I get the following error
npm ERR! Unexpected end of JSON input while parsing near '...-4","#angular/common"'
I tried to force clean the cache and re-try but still face the same problem.
NodeJS version: 12.16.3
npm version: 6.14.4
Angular CLI version: 9.1.4
OS: Windows 10 Home win32 x64
Edit: All the commands above I run them in Powershell as administrator
This is not a definitive answer but it looks like your global packages are corrupted in some way.
This bug may be caused by many different things. I suggest doing the following.
Install Node Version Manager (or NVM for Windows) and install Node version 10.16.1. This is enough for angular 9 and from my experience it is the most stable version for development. This should also change your NPM version so that may also help.
Uninstall global angular package npm uninstall -g #angular/cli
Force clear cache npm cache clean --force
Just to double check npm cache verify
You can also try clearing your %temp% and %roaming% AppData/npm-cache
install latest angular package npm install -g #angular/cli#<your-version>
if this error still occurs, consider using another shell
If this don't solve the problem try to manually locate the package.json file that is throwing an error and investigate.

node wont update angular

I have been struggling for days to try and get angular to update. I have finally narrowed it down to the fact when I run
ng new
it creates an angular app using version 1.7.4 but I have updated angular to version 8.1.2. when I run
ng --version
I get the message "your global version is 8.1.2 is greater than your local version 1.7.4 the local version will be uses"
I have run npm
npm update -g#angular/cli
npm update #angular/cli
but nothing. I have also deleted the files in
c:\users\user\appdata\roaming\npm\node_modules\#angular
and tried running
npm install #angular/cli
Has anyone got any idea either how to update my local install of angular or when I run
ng new
to get it to use the global version?
Thanks
npm update will update your package to the latest safe version, i.e. it won't increase a major version of your current package which is 1 in your case. A change of a major version means there will be breaking changes.
So you need to explicitly specify the package version to which you want to migrate. I.e. npm update #angular/cli#^8.1.2 or npm install #angular/cli#^8.1.2, sorry I mostly use yarn so not sure which of these 2 commands will work.

Angular - TypeError: Cannot read property 'write' of undefined

I'm working on a club project and we are using angular for our platform, I'm just doing front-end homepage stuff, so technically I just use the angular stuff to run and test.
It was working fine but now everytime I run ng build --watch I get this error:
C:\Users\User\Documents\WebstormProjects\MyProject\angular-src\node_modules\#angular\cli\ember-cli\lib\ui\index.js:56
this.outputStream.write(data);
^
TypeError: Cannot read property 'write' of undefined
at UI.write (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\#angular\cli\ember-cli\lib\ui\index.js:56:23)
at UI.writeLine (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\#angular\cli\ember-cli\lib\ui\index.js:69:8)
at Watching.callback [as handler] (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\#angular\cli\tasks\build.js:44:29)
at Watching._done (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:106:8)
at compiler.emitRecords.err (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:79:19)
at Compiler.emitRecords (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:371:38)
at compiler.emitAssets.err (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:62:20)
at applyPluginsAsyncSeries1.err (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\Compiler.js:364:12)
at next (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:218:11)
at Compiler.compiler.plugin (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\webpack\lib\performance\SizeLimitsPlugin.js:99:4)
at next (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:220:14)
at Compiler.compiler.plugin (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\#ngtools\webpack\src\plugin.js:326:13)
at next (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:220:14)
at callback (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\copy-webpack-plugin\dist\index.js:126:17)
at Compiler.afterEmit (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\copy-webpack-plugin\dist\index.js:220:13)
at Compiler.applyPluginsAsyncSeries1 (C:\Users\user\Documents\WebstormProjects\MyProject\angular-src\node_modules\tapable\lib\Tapable.js:222:13)
I'm totally lost around this, I've tried multiple threads to reinstall node and angular and nothing.
I've followed this one in particular: How to uninstall Angular CLI? .
The weirdest part is now when I try to do this on ubuntu by cloning the project, setting the env variables and do npm install, every time I do ng watch build it gives me the same error. But apparently, I'm the only one on the team.
It's because of the new Angular version. Go with the old Angular version:
npm uninstall -g #angular/cli
npm install -g #angular/cli#6.0.8
Seems to be caused by latest version of Angular CLI (released today). I worked around it by installing previous version (6.0.8) globally.
Update:
As per prionp answer below:
Angular CLI v6.1.2 fixed the issue.
Update your version :
npm update -g #angular/cli
I have tried to install angular(version 6.1.1 and 6.1.0 and 6.0.9). unfortunately, I have faced error in all of mentioned versions. But, I could install angular 6.0.8 successfully.
try this command in your console:
npm uninstall -g #angular/cli
npm install -g #angular/cli#6.0.8
Angular CLI v6.1.2 fixed the issue.
Update your version :
npm update -g #angular/cli
Faced the same issue, its related to both 6.10 and 6.11, one option is to downgrade your #angular/cli to 6.0.8 or to update the local #angular/cli manually
Change #angular/compiler-cli version in your package.json, to the same version as #angular/core and the others.
And then, run an npm update to get the updated version.

Fresh install of npm and node

I have recently started working with Angular 2 and am unable to get the Angular 2 Quickstart project to run correctly due to a number of errors in my npm dependencies.
Am I able to globally uninstall everything that was previously installed with npm to allow me to do a clean install of it and any required dependencies?
Note: The errors are the same as these examples which are caused by packages needing to be installed globally, however, the errors still occur having followed these steps...
To check your global installed packages you can type:
npm ls -g --depth=0
That lists all global installed packages with depth=0. That mean that it doesn't output dependencies of the packages. You can uninstall global packages with:
npm uninstall -g package-name
Please do not uninstall the npm package itself... But you can update your npm version with npm:
npm install npm -g
As mentioned in the Article your Node.js version should be at least v4.x.x and the npm version should be v3.x.x. You can get the installed versions with these commands:
node -v
npm -v
Updating your Node.js depends on your Operating System. Assuming that you use Windows you should uninstall the current version via control panel and download an actual release from the official Node.js page. https://nodejs.org/en/download/current/
To get a great overview how npm works you should consider reading their
documentation: https://docs.npmjs.com/
Make sure you have the correct node.js version. The guide says 5.0 or greater but points you to the wrong download link.
Try this: https://nodejs.org/en/download/current/
With this node you should be able to follow the guide step by step.

Resources