Typescript is not removed even after reinstalling node - node.js

While working on Angular 5 project, I got the following error on compilation :
#angular/compiler-cli#5.2.11 requires typescript#'>=2.4.2 <2.7.0' but 2.7.2 was found instead.
Using this version can result in undefined behaviour and difficult to debug problems.
Please run the following command to install a compatible version of TypeScript.
npm install typescript#'>=2.4.2 <2.7.0'
To disable this warning run "ng set warnings.typescriptMismatch=false".
To fix this error did the following:
Deleted all node_module instances, and uninstalled node from control panel -> add/remove programs.
Reinstalled node
Checked in cmd:npm view typescript version
I received version as 3.2.2
npm uninstall -g typescript
npm cache verify
Still typescript is not removed from npm.
Can some one help me uninstall typescript completely? Been stuck on this for 2 days now.

It seems there is a small mistake in compiler log:
Please run the following command to install a compatible version of TypeScript.
npm install typescript#'>=2.4.2 <2.7.0'
should be
npm install typescript#">=2.4.2 <2.7.0"

Maybe there is a mismatch in your package json. Update the typescript version as suggested and update package.json
run:
npm install typescript#'>=2.4.2 <2.7.0' --save

Check following step:
You call #angular/compiler-cli in global or local(just one folder), you need install typescript same.
Install typescript match '>=2.4.2 <2.7.0', example : typescript#2.6.2, local or global with -g.
Try close your cmd, reopen it (if typescript install global, cmd don't know it change if you don't reopen).
Check your eviroment variable NODE_PATH, if it exist, go to that folder to remove module in that.
To check NODE_PATH, type in your cmd : echo %NODE_PATH%

Related

Cannot find module 'fs/promises' Electron JS

Good morning,
I have created a program in Vue JS, this connects with an API that I have created in a main.js file to execute system commands.
The problem I have is that when compiling for production with electron I get the following error:
I use the command npm run electron: build
When I use npm run electron:serve work without problems
Anyone have any idea why is the error and how to fix it?
Thanks
I experienced this issue a few days ago as well. I realized that trying to fix another issue, I deleted the node_modules folder and the package-lock.json file, then run the npm install command. This made the build to fail with 'fs/promises'. There are 2 solutions to this issue:
Download the latest stable Node version. This should have the 'fs/promises' module and will fix the issue.
Delete the node_modules folder and bring back the old package-lock.json file to ensure that the package versions remain the same. Then run the npm install command and the issue should be fixed.
downgrade electron
"electron-builder": "^22.10.5",
or upgrade nodejs to 14+ v
downgrade to "electron-builder": "~22.10.5" is working for me
In that case I fixed the problem in that way:
const fs = require('fs').promises;
Instead of:
const fs = require('fs/promises');
In my case I was using nvm to manage multiple node versions.
During the npm package installation, and throughout development, I used Node v14 but for some reason, my terminal was pointing to Node v12 when I tried bundling my program afterwards.
Switching it back to Node v14 using nvm use 14 solved my issue.
So make sure you're using the correct node version.
Upgrade to electron-updater#5.0.0. It has patch changes replacing fs/promises with fs-extra to support legacy versions of electron.
got the same error "Cannot find module 'fs/promises'" while I don't use electron.
so the problem is not only related to electron
solved the problem just by upgrading nodejs from v13.9.0 to v14.19.3
If this happens to you (and I'm not using Electron either), and you have to stay on Node 12 like me (because the code you are maintaining is ancient), pray that you can get to one of the npm-shrinkwrap.json files you used that worked, then go through package.json, force every version to what was in the shrinkwrap file, rm -rf node_modules, and npm install.
I experienced this issue a few days ago. I realized that trying to fix another issue, I deleted the node_modules folder and the package-lock.json file, then run the
npm install
This made the build to fail with 'fs/promises'.
Delete the node_modules folder and bring back the old package-lock.json file to ensure that the package versions remain the same
then run the npm command with force
npm install --force
it work for me..
I had the same problem, after upgrading the electron-builder from v. 21.4.0 to 23.0.2, updated with the command:
 
sudo npm install -g electron-builder#23.0.2
I solved updating npm, and then node.js.
Update npm:
sudo npm install -g npm#latest
 
Install nodejs from https://nodejs.org
Now it works with :
 
Electron-builder: 23.0.2 (command electron-builder --version)
Npm: 8.7.0 (command npm --version)
Nodejs: v16.15.0 (command node --version)

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.

Cannot Find name Partial

I am using ngx-bootstrap 1.9.2 npm package, but when I try to compile, my project, angular throws following error:
ERROR in C:/xxx/xx/node_modules/ngx-bootstrap/datepicker/bs-datepicker.component.d.ts (46,15): Cannot find name 'Partial'.
ERROR in C:/xxx/xx/node_modules/ngx-bootstrap/datepicker/bs-daterangepicker.component.d.ts (45,15): Cannot find name 'Partial'.
As Partial was introduced in ts version 2.1, I tried upgrading typescript version from 2.0.0 to 2.5.2 nothing helped.
we use typescript 2.4.2, because it's mandatory for angular#5.
What can help:
check global version of typescript
check local version of TS (and clean install and clean build)
if you are using Visual Studio, it has addition TS version
(this link may help https://github.com/Microsoft/TypeScript/issues/5995 )
It was just cache issue, I just perform npm cache clean and performed clean install and my problem was solved.
By the way thanks all, for your comments and answers.
For me it worked after doing the following steps.
install the latest typescript version globally. use below command.
npm install -g typescript#latest
Clean the npm cache using
npm clean cache
Install the latest typescript locally.
npm install -g typescript#latest
And it worked for me. Hope it helps.

Angular-cli - Cannot serve project after updates

I have updated both npm, node and angular-cli to the latest versions. Now, when I run the ng serve command in my existing working project, it gives the error below
ERROR in ./src/main.ts
Module build failed: TypeError: Cannot read property 'newLine' of undefined
at Object.getNewLineCharacter (/home/bunyamin/WebstormProjects/c3dp/node_modules/typescript/lib/typescript.js:8062:20)
at Object.createCompilerHost (/home/bunyamin/WebstormProjects/c3dp/node_modules/typescript/lib/typescript.js:44978:26)
at Object.ngcLoader (/home/bunyamin/WebstormProjects/c3dp/node_modules/#ngtools/webpack/src/loader.js:202:31)
# multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
I also noticed that when I run npm run start command, which is ng serve in the package.json, it say Environment configuration does not contain "source" entry. which is changed in new version of angular-cli. I suspect that the npm does not know about the new version of angular-cli but is it possible?
Can anyone who faced this problem before help me to fix it?
Remove your node_modules, then run npm cache clean and after it re-install them. It's all about newLine error.
What about angular-cli, if you work with newest version (#angular/cli), you need also to install it globally

dyld: lazy symbol binding failed: Symbol not found: _node_module_register

I have tried reinstalling and rebuilding npm, but the problem still persists.
Initially, the problem is with the module mongodb: I don't have that package, so I installed mongodb using this command npm install mongodb.
It shows me the following error:
dyld: Symbol not found: _node_module_register
Try deleting your node_modules folder and running npm install again.
rm -rf node_modules/
npm install
That should fix it.
Basically this error means - some binary packages was built under different node.js versions and not compatible to each other.
Via NVM make sure you are using proper version of node.js, run node -v;
After installing and switching to proper node.js version via nvm run npm update;
After all packages are updated (or downgraded) to compatible versions, run npm rebuild;
Note: npm rebuild might throw errors - just run npm rebuild again and again until it runs successfully.
Note: some commands may ask for root (sudo) permissions, - it depends from how you have installed packages, npm and node itself previously. nvm - never needs to be run as root (sudo).
If you just updated node and are running scripts via WebStorm, make sure you edit your Run/Debug Configurations and update the path to the Node Interpreter. I was using the node in
/usr/local/bin/node
, but after installing Node 4 using nvm, I need to use
/path/to/.nvm/v4.2.2/bin/node
This is what worked for me:
rm -rf node_modules/
sudo npm install
Make sure your nvm is pointing to the correct nodejs version. For me I used different (higher) while installing the npm modules. So just ran **nvm use** v14.7.0

Resources