(NOTES) NOTES (2023)

Node.JS Configuration - set Angular, Typescript, Nativescript, NPM custom location.


If you are very basic and restricted user - you will always default on any program and you will search only button OK on the screen. But if you want something more, for example increase performance, reduce space on disk C:\ and so on, you will always custom location to any you program.

Node.JA use quite strange and difficult to understand logic to location configuration files files. For example, I have installed Node.JS to D:\NodeJS folder, but main configuration of Node.JS (placed on D:\nodejs\node_modules\npm\npmrc) contains reference to another protected place with configuration of Node.JS - to place C:\Users\XXXXX\.npmrc and configuration on place C:\Users\XXXXX\.npmrc refers backward - again to D:\Node.JS.



This strange logic induce strange hierarchy of overriding various configuration parameters. And there are only one way to understand this hierarchy.


#npm config ls -l
...
; "builtin" config from D:\nodejs\node_modules\npm\npmrc
; prefix = "C:\\Users\\XXXXX\\AppData\\Roaming\\npm" ; overridden by user
; "user" config from C:\Users\XXXXX\.npmrc

Pay attention that any node_modules additionally to (1) global installation also has (2) CACHE and (3) installation to project locally and [1] NPM, [2] NodeJS, [3] Angular, [4] TypeScript, [5] NativeScript - all of this components has own system on version numeration, independent one from another. In reality this is hell, because (for example) changing one Angular version to another is not a simple process https://update.angular.io/.

So, You have a lot of incompatible versions of each development tools, placed in many location (locally in project, globally and in cache).



And additionally overriding from one configuration to another! Additionally. a couple of configuration you can change only as administrator (C:\Users\XXXXX\.npmrc) and some configuration can not influence to anything, because it always overridden or overwriting (as cache).


How to prune this hell logic? In order to simplify this logic I propose to delete first dumb reference from D:\NodeJS configuration to C:\Users\XXXXX\.npmrc and change prefix from $(APPDATA)\npm to D:\nodejs

prefix=$(APPDATA)\npm
prefix=D:\nodejs

This way allow me to avoid overriding and place each development tools to custom location.



Additionally you need to add


D:\nodejs\
D:\TypeScript\node_modules\.bin
D:\Angular\node_modules\.bin\

To PATH variables on your computer.



This is full reference to NPM configuration https://docs.npmjs.com/cli/v9/using-npm/config, https://stackabuse.com/the-ultimate-guide-to-configuring-npm/.


And this is only a start to tune Node.JS, time on time we receive strange error message during building Angular software, for example.



In this case we need to install Node.JS version manager.



And can manipulate version of Node.js



In any case, in my opinion, the best way is create new project in your current development environment:


# ns create myProject --ng
# ng new myProject

and than try ro restore additional packages one-by-one from your old existing project.

However, in reality programming with Node.js we faced with a lot of various troubles, for example sometimes JS-library try to updates directly inside protected directory.



In this case solution is

# Start-Process powershell -verb runas
# npm cache clean --force
# npm i

Nuget Configuration.

And, of course, If you are not basic user who can only search button OK on the screen, you will locate Nuget cache to separate TEMP disk.



By default packages stored to C:\Users\XXXXXX\.nuget (%userprofile%\.nuget\packages), but this is idiotic solution from Microsoft, to upload disk C:\ as possible. This solution can satisfy only lowest level basic users. Any other user refers this folder to special TMP place.



This is full documentation to Nuget configuration https://learn.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders.

Junction - ultimate step of optimization you working environment.



More Optimize windows performance by Junction.



Comments ( )
Link to this page: http://www.vb-net.com/NodeConfig/Index.htm
< THANKS ME>