Install Typing packages behind corporate proxy - typescript-typings

I'm getting the error message below. I searched for the self signed certificate problem and I got to this answer, but I did everything that is mentioned here. I'm just going around and still no success.
What I did so far:
I have a .typingsrc in my %USERPROFILE% directory containing the example below
I have another .typingsrc file in my project root containing the example below
I have tried every combination of the example below
Questions:
where the .typingsrc file should be placed in Windows 7?
Where can I find a documentation about properties of .typingsrc file? It is always just mentioned and there is no example with parameters.
Is .typingsrc a JSON file or something else?
Still no success.
Do you have a solution for this?
{
"rejectUnauthoriozed":false,
"httpProxy": "",
"httpsProxy": "",
"insecure":true,
"strict-ssl":false
}
Error message:
C:\..\src\UI.Spa>typings install dt~angular --global --save
typings ERR! message Unable to connect to "https://api.typings.org/entries/dt/angular/versions/latest"
typings ERR! caused by self signed certificate in certificate chain
typings ERR! cwd C:\..\src\UI.Spa
typings ERR! system Windows_NT 6.1.7601
typings ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\..\\AppData\\Roaming\\npm\\node_modules\\typings\\dist\\bin.js" "install" "dt~angular" "--global" "--save"
typings ERR! node -v v5.10.1
typings ERR! typings -v 1.1.0
typings ERR! code EUNAVAILABLE
typings ERR! If you need help, you may report this error at:
typings ERR! <https://github.com/typings/typings/issues>

My .typingsrc file is located at the project root level (where typings.json is located).
It simply contains:
proxy="http://xxx.xxx.xxx:80"
rejectUnauthorized=false

If you're working at a corporate company that blocks/restricts commands such as npm install, you'll need to setup a proxy which allows you to bypass that. I'm assuming if you've gotten this far, you've already done that. Make sure you remember the proxy you used so that you can add it to the .typingsrc file in the next step.
Just create a .typingsrc file in the root of your project and paste the following:
proxy="http://xxx.xxx.xxx:8080" (this is where you paste the proxy you used)
rejectUnauthorized=false
After doing this, you should be able to run your global typing commands without errors.

Try "--proxy" option.
For example
C:\..\src\UI.Spa>typings --proxy "http://xxx.xx.xx.xx:8080/" install dt~angular --global --save

Related

How to fix `sh: ___: command not found` for NPM Modules

I'm relatively new to Node development and I'm trying out various modules, frameworks, etc.. I'm on macOS Catalina. I've changed my NPM root and $PATH while trying to get things to work, and I think I broke something, though I'm not exactly sure what. My issue is very specifically with NPM, which is having a persistent problem running installed modules both locally and globally. When I try to install a dev tool like Nodemon or a framework like Electron, I get error codes like:
sh: electron: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! electron-quick-start#1.0.0 start: `electron .`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the electron-quick-start#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I've consulted a lot of resources and a lot of questions on this site, but I'm not experienced enough to accurately troubleshoot this issue and identify what's going on. While I'm shooting in the dark, I may be fixing one thing and breaking another, so I'm coming here to see if I can get a comprehensive answer.
I'll add that I've found a few workarounds, if this makes the issue clearer at all. I can get some modules (in this example Nodemon) to run by adding this "dev" script to the package.json:
"scripts": {
"dev": "node ./node_modules/.bin/nodemon server.js"
}
So I can access local project modules by specifying the path of the Module, but I can't just say "nodemon server.js", either in the dev script or from the command line, where it should have been installed globally. If I look in the specified npm -g root folder, the packages I'm trying to run are definitely in there, so it's not an installation issue.
Any guidance y'all have is greatly appreciated, as I don't know what to make of all this.
There are 2 installation style, local and global, on npm.
It is highly recommended to not mix both on the same environment, at least for a given module.
Global installation
e.g. npm install -g <module name>
The executable(s) provided by the module you have installed will be added into the place which PATH environment variable includes.
You can then use this command everywhere (here electron or nodemon), but you cannot use different versions for each project in your environment. You can isolate this behavior with nvm, or better in a container.
Local installation
e.g. npm install --save <module name>
The executable(s) will be installed into the project node_modules directory and saved in the package.json.
You can then use different versions of the module for each project and easily manage it with package.json.
PATH environment variable does not include there, so you have to use ./node_modules/.bin/<command>, as you did in your workaround, or $(npm bin)/<command>.
You can also use any command provided by the module in npm-scripts even if it's a local install because npm adds ./node_modules/.bin to PATH before npm run-script command.
See also: https://docs.npmjs.com/cli/v7/commands/npm-run-script

Unable to find "dt~mocha" ("npm") in the registry

I am trying to setup mocha and chai in my current typescript project.
I am going through below page to implement the same:-
https://journal.artfuldev.com/write-tests-for-typescript-projects-with-mocha-and-chai-in-typescript-86e053bdb2b6
$ typings install dt~mocha --global --save
I am getting error while running above command in Ubuntu:-
typings ERR! message Unable to find "dt~mocha" ("npm") in the registry. Did you want to try searching another source? Also, if you want to contribute these typings, please help us: https://github.com/typings/registry
typings ERR! caused by https://api.typings.org/entries/npm/dt~mocha/versions/latest responded with 404, expected it to equal 200
typings ERR! cwd /home/abhishek/Desktop/TypeScript/automation/jasmine
typings ERR! system Linux 3.19.0-47-generic
typings ERR! command "/usr/local/bin/node" "/usr/local/bin/typings" "install" "dt~mocha" "--global" "--save"
typings ERR! node -v v7.7.3
typings ERR! typings -v 0.8.1
typings ERR! If you need help, you may report this error at:
typings ERR! <https://github.com/typings/typings/issues>
I tried searching the internet. Also, I tried a couple of things but it failed.
Any ideas on this on how can I fix my problem?
I went through the page and instead of running below commands:-
$ typings install dt~mocha --global --save
$ typings install npm~chai --save
I see there is a command on the page you have shared which you can use:-
There is now another method to add type definitions, from TypeScript 2.0, so we can also use that instead of the typings method mentioned above. This method does not depend upon the typings npm package or module. To make use of this, type the following commands:
$ npm install #types/chai #types/mocha --save-dev
I followed the rest of the steps and it worked !!!
I know this may not be the ultimate solution but should do.

npm install no longer possible after deleting module directory

So I wanted to help out, and forked a Node-RED module to make some small contribution, but then got lost messing around with how to get Node-RED to run my fork (for testing) rather than the packaged version. Then I learned about npm's ability to install from a Github URL, which is nice, but it wouldn't work because I had already installed the module. Then I found I couldn't uninstall it either
npm uninstall original-module
npm ERR! path /home/nodered/.node-red/node_modules/original-module/package.json
npm ERR! code ELOOP
npm ERR! errno -40
npm ERR! syscall open
npm ERR! ELOOP: too many symbolic links encountered, open '/home/nodered/.node-red/node_modules/original-module/package.json'
so in frustration I deleted the module's directory, only to find myself unable to move forwards, or backwards. npm install https://github.com/me/forkedmodule fails with
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master https://github.com/me/forkedmodule.git /root/.npm/_cacache/tmp/git-clone-d31dc53b
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-d31dc53b': Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-08-22T01_07_18_257Z-debug.log
and trying to install the original with npm install original-module fails with
npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules/original-module" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-08-22T01_09_56_127Z-debug.log
As you've probably guessed, I'm pretty new to Node.js, Node-RED and npm, but I haven't been able to help myself, so have to ask for help! It seems nonsensical to me that npm appears to be looking for a local copy of the package.json file belonging to the package I'm trying to install?
Edit: I should add that the above commands were all run as root.
Ok, found a solution, not sure if it's the best one though!
In the "project" directory (/home/nodered/.nodered in my case) there's a package-lock.json file which lists the packages used by the project. In there I found an entry for the original-module which I removed, after which I was able to install the package "normally" with npm install original-module.
Then to solve the permission issue when installing from a GitHub URL, I found I needed to impersonate the "nodered" user with su - nodered (it's a password-less user in my case). As "nodered" npm install https://github.com/me/forkedmodule succeeded without any error. A little curious since I was trying to do this as root before, and got a permission error, but there you go. I also took the opportunity to chown -R the project's node_modules directory to nodered:nodered as I could see that was a bit of mess.
In future, I will try to remember to su - to my nodered user first, and navigating to the project root (again, /home/nodered/.node-red in my case) before running npm install anything. Hopefully that will avoid any further issues. Oh and a note to anyone else who just wants to contrib some quick changes to a module hosted on GitHub: to "pull" in changes you simply run npm install https://github.com/me/forkedmodule again - npm doesn't appear to provide any dedicated "update" method.
I had the same issue, in my case the solution was to delete the package-lock.json, delete node_modules, then reinstall npm modules.

How can I add a .npmrc file?

I installed node on my Mac OS Sierra. I use Windows at my work so there I have a .npmrc file in the node folder but I don't seem to find that in mac.
The problem is I want to add a registry of the format
"scope=rohit-project#rohit-aquila:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=some-token"
How do I add it so that I can install the dependencies and modules for my project by running npm install on MAC OS Sierra.
I created a .npmrc file simply and added the above code...and therefater running npm install I get the following error
rohitsrivastava$ npm install
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.7.3
npm ERR! npm v4.1.2
npm ERR! code E404
npm ERR! 404 Not found : #rohit-project/notes
npm ERR! 404
npm ERR! 404 '#rohit-project/notes' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of '#rohit-project/mega'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
There are a few different points here:
Where is the .npmrc file created.
How can you download private packages
Running npm config ls -l will show you all the implicit settings for npm, including what it thinks is the right place to put the .npmrc (the field userconfig), as this is environment/operating system dependant. But if you have never logged in (using npm login) it will be empty. Simply log in to create it.
To just output the path prop, issue npm config get userconfig.
Another thing is #2 - downloading private packages. You can actually do that by putting a .npmrc file in the NPM package's root. It will then be used by NPM when authenticating. It also supports variable interpolation from your shell so you could do stuff like this:
; Get the auth token to use for fetching private packages from our private scope
; see http://blog.npmjs.org/post/118393368555/deploying-with-npm-private-modules
; and also https://docs.npmjs.com/files/npmrc
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
Pointers
http://blog.npmjs.org/post/118393368555/deploying-with-npm-private-modules
https://docs.npmjs.com/files/npmrc
In MacOS Catalina 10.15.5 the .npmrc file path can be found at
/Users/<user-name>/.npmrc
Open in it in (for first time users, create a new file) any editor and copy-paste your token. Save it.
You are ready to go.
Note:
As mentioned by #oligofren, the command npm config ls -l will npm configurations. You will get the .npmrc file from config parameter userconfig
This issue is because of you having some local or private packages.
For accessing those packages you have to create .npmrc file for this issue. Just refer the following link for your solution. https://nodesource.com/blog/configuring-your-npmrc-for-an-optimal-node-js-environment
In my case, updating my npm version helped me. So just to be sure, make sure your npm is up to date.
npm install -g npm#latest
Assuming you are using VSTS run vsts-npm-auth -config .npmrc to generate new .npmrc file with the auth token

npm install error code EBUSY errono -4082

I am running windows7 and have just installed the following...
c:\design_centre_dev\workspace>node -v
v5.10.1
c:\design_centre_dev\workspace>npm -v
3.8.6
I'm having issues running npm install on my node project which one of my fellow dev's says he has no trouble with and should work for me.
When I run npm install i am getting errors like...
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\rriviere\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v5.10.1
npm ERR! npm v3.8.6
npm ERR! path c:\design_centre_dev\workspace\node_modules\path-type
npm ERR! code EBUSY
npm ERR! errno -4082
npm ERR! syscall rename
npm ERR! EBUSY: resource busy or locked, rename 'c:\design_centre_dev\workspace\node_modules\path-type' -> 'c:\design_centre_dev\workspace\node_module
s\.path-type.DELETE'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
It seems to throw these same types of errors for modules asynch,path_type and isarray and does not want to get past them.
Can anyone suggest what might be wrong?
EDIT
Thanks for the suggestion of this thread possibly being answered somewhere else. I had a look and I believe it is a different problem. I think this because I've been investigating further today and I think the problem is that the node_modules directory which npm is creating. The permissions on that directory don't seem to be right. I think this might be an issue and probably a new thread so I'll close this one and create a new.
If you have open that node module file in your editor then just close the file from the editor
Or
Close Editor Software
Then Try again
The cause of this was windows permissions problems. My work computer did not have privilleges to do certain things. When I moved to my personal mac everything just worked.
I got this error when tried to uninstall/re-install a module on Win10 VM. "npm cache clean", as suggested by some, did not work. Restarting the system resolved the issue.
This issue may links to country boycott or computer limitation. I live in a country which is boycott and I could rise that with turn on VPN and then do the process of installation. Please follow this:
npm run cache clean ---force (remove node_modules)
Turn on VPN (set it based on country which isn't boycott)
npm install
I met the same problem today. I found that is because I npm run in a terminal and npm install in another terminal. The file was occupied. I just delete the node_modules and npm run again.
This is an underlying issue of Anti Malware software blocking your application from connecting to node package manager (npm).
I am using Bullguard and disabling my Antivirus seemed to do the trick!
I was facing the same problem for 3 days and got this solution for it...
It's because of old files lying in your c drive:
Follow the steps below and try, It will work for sure.
problem:
npm ERR! Errno: -4048,
npm ERR! code: ‘EPERM’,
npm ERR! syscall: ‘scandir’,
solution:
Uninstall node with node uninstaller ( find it from run cmd )
Then...
Delete the npmrc file and delete the C:\Users\Administrator.npmrc file ( if don't find leave it )
Delete npm-cache folder from - C:\Users\Administrator\AppData\Roaming
Delete npm folder from - C:\Users\Administrator\AppData\Roaming
Restart your system and install fresh NodeJS and run this command in cmd: npm cache clean -–force to ensure the cache is cleared.
That's your ready to go now...
If you still face a problem feel free to get in touch with me #ishaiknadeem username on any platform
Just close the terminal and turn on a new one, then 'npm install' it works on me.

Resources