npm installing wrong version of anuglar(8.1.0) - node.js

when i run the following command, it shows 6.4.1.
npm run ng --version
but when i am running the following command, it is installing 8.1.0 and getting error. i do not understand how it is happening.
npm install -g #angular/cli
i tried the following commands. but it is not working
npm cache clean --force
npm install -g #angular/cli
Error Screen
My Requirement:
Angular 6
how can i resolve this?

You should the latest (12+) node when upgrading to angular 8. You can download it from here.
After upgrading node, the issues should go away.

For simple use cases and thanks to the work done in Angular 8, you can upgrade to the latest release using one command:
$ ng update #angular/cli #angular/core
After running this command, the lazy loaded routes will be automatically migrated to the new import syntax which is standard compliant and brings Angular close to the open web platform.
You also need to be aware of the following issues when upgrading your project:
Angular 8 makes use of the latest TypeScript 3.4, so even if the upgrade process completes with success you might have some syntax errors that may be due to the better type inference system used by the latest version which detects new potential typing issues but in the end this will improve your code quality and helps you avoid bugs in the future. You can see the new features of TypeScript 3.4 from the official docs.
You need to have Node.js 12+. Simply run node -v to verify your Node version. You can install the latest version from the official website

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

ReferenceError: primordials is not defined error when installing Semantic UI

I know that this question had been asked a lots of times (for instance - here), but either solutions didn't work or didn't fit my scenario.
The solution, offered in the link above, was:
Solution: Either upgrade to gulp 4 or downgrade to an earlier node.
So, here's what I have:
• Node: 12.18.1 (node -v)
• Gulp: CLI 2.3.0, Local version 4.0.2 (gulp -v)
I have created brand new react app:
npx create-react-app --template typescript react-app
Then I go to app folder (react-app) and execute the following command as on Semantic UI site:
npm install semantic-ui --save
However, I get the same error as in the question above. Here's the full output of this command:
If you don't want to roll back your version of Node, try using the actively maintained community fork of Semantic UI: Fomantic UI.
Run the command as you would with semantic-ui: npm i fomantic-ui
Fomantic is backwards-compatible with Semantic UI while resolving compatibility issues between Node 12 and Gulp 3 (which another thread references as being the root of the "primordials is not defined" issue).
Try going back to Node v10.
The thing is that Node v12 has a feature that is not compatible with Semantic-UI (Gulp 4.0.2), and that's why you get the error.
Please try upgrading your node.js to the latest version at https://nodejs.org/en/download/
and also run the following command npm install -g npm#7.0.9 or the latest version to update your npm.
After upgrading and updating Node and npm I installed semantic-ui without getting the primordial not defined error.

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.

Node JS 6.9 and angular CLI version compatibility

I have a restriction of using node JS version 6.9.1. I am getting many problems, while using angular cli quick start steps.
after ng serve, browser page will be white, no error in console.
npm start works, but if i change some style/file browser do not not refresh.
if i make any style change, webpack compiled successfully message comes but webserver fails to load page.
When I follow the quick start steps with latest nodejs it works like a charm. Can any one help me in telling, what are the versions (npm, angular-cli), I should use to run it ?
Like
Each Angular/Cli version has limited its compatibility of node versions below a specified release. If you have to use a specific version of node then your best bet would be to find a previous version of the Angular/Cli that will play nicely.
Here you can find all the versions and from there, pick one a little further back in the list and then do a search in google for "Angular/cli version x.x.x node compatibility" to see if there are any known issues.
Once you pick a version that looks good, run
npm install -g #angular/cli#<your version number>.
Once the install is complete run ng help and you'll get feedback right away if the version is still incompatible and you can try a different version.
Just make sure you get rid of the installs you aren't using with npm uninstall -g #angular/cli#<your version number>
for see if angular-cli is compatibility whit your node version installed you can see https://www.npmjs.com/package/#angular/cli/v/6.0.8?activeTab=versions, for example, I have installed node 6.11.2 and I have to use: npm install -g #angular/cli#6.0.0

Resources