How can I diagnose why `npm publish` quietly does... nothing? - node.js

I've created a npm package following several different sets of instructions online. Here is what I have: https://github.com/joelarson4/CharFunk/blob/master/package.json
When I do an npm publish, I get a single newline of output (no errors, no anything). But from what I can tell, my package is not on npmjs.org. https://www.npmjs.org/package/CharFunk is an error page.
How can I figure out what I'm missing?

You solved your problem, but for others; You might see more information with:
npm publish --verbose

You might have loglevel set to silent. Try doing
npm config set loglevel verbose --global
and then rerunning your npm commands to see if that gives more useful detail.
If not, try editing ~/.npmrc and setting
loglevel verbose
The extra information provided should help clarify the problem.

I did have similar problem working with our local Nexus server.
NPM v6 is not able to handle the HTTP Status 302. It understands this code as success printing npm http fetch PUT 302 into verbose output. It happened in my case, as the Nexus server expected the connection over https and the firewall redirected all the requests from port 80 to 443.
To fix it, I changed the publishConfig in the package.json referencing the Nexus server over https.
"publishConfig": {
"registry": "https://nexus.example.com/repository/npm-private/"
},
NPM v8 handles redirects correctly and doesn't need this fix.

Related

npm ETIMEDOUT code EMAXREDIRECT when running command npm i baconjs#0.7.88 -save

When I try to run the following command npm i baconjs#0.7.88 -save behind the proxy i get the ERR! code ETIMEDOUT error.
I have been getting this error when I am not logged on to the VPN. Now I have attempted all methods. Setting and Unsetting the proxies numerous times. Logging on and off the VPN with the proxies set/unset. no luck.
One thing I have noticed though is when I set the proxies and I have not logged on the vpn I get that error above (ERR! code ETIMEDOUT) but when I log on to the VPN and run the command I get a different error this time which is:
npm ERR! code EMAXREDIRECT
npm ERR! maximum redirect reached at: https:// registry.npmjs.org/registry.npmjs.org:
What do I need to do to get npm to successfully complete this command
npm i baconjs#0.7.88 -save. So frustrating this is, been at it for a couple of hours and I feel like putting this thing in the bin but I don't own it.
Different proxy methods I have tried
npm config set proxy http: //username:password#companyvpn.xx.xx:
npm config set https-proxy http: //username:password#companyvpn.xx.xx:
npm config set proxy http:// username:password#companyvpn.xx.xx
npm config set https-proxy http:// username:password#companyvpn.xx.xx
npm config set proxy http:// companyvpn.xx.xx
npm config set https-proxy http:// companyvpn.xx.xx
you would expect the first set of config to work but NO.Eventually I ran out of ideas
I tried with
npm config set https-proxy http://proxy:8080
It worked for me
Eventually I resorted to doing the install manually (downloading from github). It turns out that the problem had nothing to do with the npm config.
To fix this, the machine had some Enviroment Variables that are confingured for HTTP and HTTPS_PROXY. Before I was configuring these to match those of the npm config but no success.
What I did was delete these variables, they can be accessed via settings "Edit environment variables for your account". On windows > "Type here to search" located bottom left next to windows menu.
I deleted these variables and deleted the npm proxy config settings as well and then logged on to the company vpn, run npm and it was successful.
Behind the vpn proxy, I now only need to config npm with the company vpn and port number like so:
npm config set proxy http:// companyvpn.xx.xx:portNumber
npm config set https-proxy http:// companyvpn.xx.xx:portNumber
Some companies require adding username and password, some don't

Installing scoped npm packages from Artifactory

I am trying to get scoped npm packages to work with Artifactory behind Apache. I can publish a scoped package to Artifactory and it creates the following path in the npm-local repo: #scopename/packagename/-/#scopename/packagename-version.tgz
My problems arise trying to install this package. I get a 404 Not Found: #scopename/packagename. Looking at the debug log I can see that maybe it has something to do with the encoding of the slashes:
22 http request GET https://artifacts.company.com/artifactory/api/npm/npm-local/#scopename%2fpackagename
23 http 404 https://artifacts.company.com/artifactory/api/npm/npm-local/#scopename%2fpackagename
I have followed the online documentation. I added AllowEncodedSlashes NoDecode to the virtual host and org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true to the catalina.properties file on tomcat.
Am I missing something?
This looks like a reverse proxy issue. Check your request.log. If the request is coming is as /api/npm/npm-group/#angular/core instead of /api/npm/npm-group/#angular%2Fcore, that is something that need to addressed in your reverse proxy.
You have to change two things:
Implement the setting org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH = true
Remove of the context root from the proxy_pass variable in /etc/nginx/conf.d/default.conf

npm publish to Artifactory results in Failed PUT 302

When I try to npm publish to a private npm repository on Artifactory I get a Failed PUT 302 error. I followed the directions in their video(https://www.youtube.com/watch?v=gyQ0riy3Hk8) and set up a remote repository that points to registry.npmjs.org, another that is the private repo(npm-local), and a virtual repo that aggregates the remote and private repos.
I set up my ~/.npmrc file to use the Artifactory virtual repo and added my credentials. I am able to install public packages fine using this setup. But when I try to publish directly to /npm-local I always get Failed PUT 302 - the repository responds with a generic nginx 302 Found page and npm can't parse the html.
Currently I am using npm#2.13.3 but I even tried reverting back to 1.4.x after reading npm publish to Artifactory not working and had the same issue.
Also I have tried publishing a directory with package.json in it and a tarball - both produce the same 302 error.
After several emails and a phone call I found the fix:
login to artifactoryonline
Goto Admin Tab
Under general settings set the Custom URL Base to: https://YOUR_ACCOUNT_NAME.artifactoryonline.com/YOUR_ACCOUNT_NAME
They said that they are working on having this set for you by default but until then you have to set it manually. Unfortunately it is not documented anywhere and not mentioned in any of the videos that I saw.
NPM v6 is not able to handle the HTTP Status 302. It process this code as successful printing PUT 302 into verbose output. It happens for example, if the Artifactory server expects the connection over https and redirects all the requests from port 80 to 443. NPM v8 handles redirects correctly.

Running npm behind a corporate firewall: what do I need to tell the security team?

I am trying to run node.js but cannot install any packages as npm is blocked. I have tried the solutions here: How to fill in proxy information in cntlm config file?, and here: NPM behind NTLM proxy and still received errors. I have tripled checked that I have followed the instructions and my ini has the same configuration as the instructions.
My next step is to ask the security team to allow npm access through the firewall, but I cannot see any documentation about this. What do I need to tell the security team?
Note: I am aware of npm Enterprise but I think before I get to that step I need to get established with npm.
Yeah, in your simplest case all you need to do is one of these
npm config set proxy http://company.com:8000
or
npm config set https-proxy http://company.com:8000
where http://company.com:8000 is your proxy server and port
(note the - dash, not _ underscore)
Also can you test access to http://registry.npmjs.org the npm registry from that machine.
Additionally your package.json also contains dependencies that require the pulling of a git repository code. You may (most likely will) need to configure git to use a proxy as well.
If you come here searching for an iptables rule:
If you want to allow only npm traffic for a certain user, the following might work:
iptables -I OUTPUT 1 -p tcp -m owner --uid-owner <username> -d registry.npmjs.org --dport 443 -j ACCEPT

Get Node.js npm command to work behind corporate proxy

I am trying to install bower
npm install -g bower
but am getting an authentication error from our proxy
...
npm http 407 http://registry.npmjs.org/bower
...
Error Code: 407 Proxy Authentication Required.
...
I am trying to get npm working behind a corprate proxy. I think our proxy is a little weird because the only way I was able to get maven downloading packages was to add wagon-http-lightweight.jar as a maven extension.
http://maven.apache.org/wagon/wagon-providers/wagon-http-lightweight/
I have tried all the regular things as described here:
Is there a way to make npm install (the command) to work behind proxy?
(I don't need to supply authentication details in my maven proxy settings).
npm config set registry http://registry.npmjs.org/
npm config set proxy http://myusername:mypassword#proxy.us.somecompany:8080
npm config set https-proxy http://myusername:mypassword#proxy.us.somecompany:8080
npm config set strict-ssl false
What else can I try?
Can try this....working for me.
Open IE (Chrome did not work for me).
Hit the URL http://registry.npmjs.org
it will download json output if successful.
Now go back to command prompt and try npm install.
I was able to get this working by installing a local proxy:
NPM behind NTLM proxy
Use fiddler http://www.telerik.com/fiddler
Install and run and that's it, everything will run as it is supposed to. I spent half a day cracking my head on this
Edit: I honestly have no idea if it was fiddler or something else I tried that fixed it (it is mostly the latter) but you should try setting registry, http-proxy, proxy and strict-ssl
When authentication is required for the HTTP proxy:
Fiddler can be configured to authenticate with the corporate HTTP proxy using NTLM or other protocols. Leave the existing auto authenticate options/rules defaults in place. Instead, go to this setting from the menu bar:
Tools > Telerik Fiddler Options > Connections tab
Click on the Allow remote computers to connect checkbox. You will see a dialog explaining the consequences of enabling this option. Restart Fiddler and update the .npmrc file as shown above. Whenever you need npm to access the registry site just run Fiddler. This setting won't affect the way Fiddler runs for other captures.
I have the same issue.
The root cause is my password contains a special character '#', when I npm set config proxy, the character become '#' in .npmrc file, so I change my password to remove the special character and it's working fine.
If your password does not contains special characters, just use syntax command below, it will work.
npm config set strict-ssl=false
npm config set proxy http://<username>:<password>#<proxy-server-url>:<port>
npm config set https-proxy http://<username>:<password>#<proxy-server-url>:<port>
Thanks,

Resources