Configuring proxy settings in npm-yeoman package

I'm currently developing my Angular application using Yeoman.

I've configured proxies and registry settings as shown below:

npm config set proxy http://proxy.tcs.com:8080

npm config set https-proxy http://proxy.tcs.com:8080

npm config set registry http://registry.npmjs.org/

Even after setting up the proxy as mentioned above, when trying to install

npm install grunt-ngmin,

I encounter the following error,

npm WARN package.json <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6b1f0e0a0618030a190e0a050c1e070a192b5b455b455b">[email protected]</a> No README.md file found!
npm http GET http://registry.npmjs.org/grunt-ngmin
npm http 407 http://registry.npmjs.org/grunt-ngmin
npm ERR! registry error parsing json
npm ERR! SyntaxError: Unexpected token <
npm ERR! <HEAD><TITLE>Proxy Authorization Required</TITLE></HEAD>
npm ERR! <BODY BGCOLOR="white" FGCOLOR="black"><H1>Proxy Authorization Required</H1><HR>
npm ERR! <FONT FACE="Helvetica,Arial"><B>
npm ERR! Description: Authorization is required for access to this proxy</B></FONT>
npm ERR! <HR>
npm ERR! <!-- default "Proxy Authorization Required" response (407) -->
npm ERR! </BODY>
npm ERR!
npm ERR!     at Object.parse (native)
npm ERR!     at RegClient.<anonymous> (C:\Users\Documents\tools\nodejs\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:235:23)
npm ERR!     at Request.self.callback (C:\Users\Documents\tools\nodejs\nodejs\node_modules\npm\node_modules\request\main.js:120:22)
npm ERR!     at Request.EventEmitter.emit (events.js:98:17)
npm ERR!     at Request.<anonymous> (C:\Users\Documents\tools\nodejs\nodejs\node_modules\npm\node_modules\request\main.js:648:16)
npm ERR!     at Request.EventEmitter.emit (events.js:117:20)
npm ERR!     at IncomingMessage.<anonymous> (C:\Users\Documents\tools\nodejs\nodejs\node_modules\npm\node_modules\request\main.js:610:14)
npm ERR!     at IncomingMessage.EventEmitter.emit (events.js:117:20)
npm ERR!     at _stream_readable.js:910:16
npm ERR!     at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9b7a9b4f499beb6b6beb5bcbeabb6aca9aaf7bab6b4">[email protected]</a>>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Users\\\Documents\\tools\\nodejs\\nodejs\\\\node.exe" "C:\\Users\\\Documents\\tools\\nodejs\\nodejs\\node_modules\\npm\\bin\\npm-cli.j
"grunt-ngmin"
npm ERR! cwd C:\nodejs\Teamshare\Teamshareangular
npm ERR! node -v v0.10.7
npm ERR! npm -v 1.2.14
npm ERR! type unexpected_token
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\nodejs\Teamshare\Teamshareangular\npm-debug.log
npm ERR! not ok code 0

What should I do to resolve this issue?

Are there any additional configurations needed in npm?

Your advice would be greatly appreciated.

Answer №1

Authentication is required for your proxy. If you have control over the proxy, you can create a user and then utilize the following commands to set up npm to use your credentials. (Make sure to include the username & password before the hostname)

$ npm config set proxy http://login:pass@host:port

$ npm config set https-proxy http://login:pass@host:port

Answer №2

If you're concerned about security, especially when it comes to your proxy credentials, it's best to avoid storing them in clear text within the npm config file.

One alternative is to set up a local forwarding proxy that handles the authentication process for you. Personally, I prefer using squid (with SquidMan), while some of my colleagues opt for Cntlm. Although Cntlm has some quirks and isn't actively maintained, I find that squid works efficiently for my needs.

I have squid running on localhost:4321 and configure npm to connect through http://localhost:4321. This setup allows squid to handle the authentication with the corporate proxy using securely encrypted credentials.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to regenerate bundle.js using npm start?

Can anyone help me figure out how NPM start functions? I have a package.json file with some scripts, but when I update the script, the bundle.js does not recompile automatically. I'm running "npm start" from the console. This is a part of my package. ...

What are the steps to run a webpack project without relying on webpack-dev-server?

I've been working on hosting my project on GitHub pages by creating a /doc file and placing all my HTML, CSS, and JS there. If you're interested, you can check out my project here: https://github.com/mattfrancis888/the_movie_db The only way I&a ...

Express authentication with repetitive login prompts appearing endlessly

Currently, I am in the process of password-protecting my node.js application using http-auth. Numerous individuals have faced similar issues, and I have attempted various solutions to address the problem. However, I seem to be encountering a roadblock. Whi ...

Is it possible to use webpack with multiple instances of express?

I am working on an application where multiple express servers are created, each serving as endpoints simultaneously. Each server serves a react app that depends on the API from its corresponding express server. I need to figure out how to use webpack to ...

Issue: unable to establish a connection to 127.0.0.1:465 to send an email

When attempting to send smtp alert messages from my site's email account <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="55363a3b2134362115383a3b263c21307b363">[email protected]</a> to the email addresses of m ...

The presence of a setupProxy file in a Create React App (CRA) project causes issues with the starting of react-scripts,

I have implemented the setupProxy file as outlined in the documentation: const proxy = require('http-proxy-middleware'); module.exports = function (app) { app.use( '/address', proxy({ target: 'http ...

Linking promises in an cascading fashion

I have been experimenting with various methods for chaining a collection of functions, but I haven't found one that I really like. The code below is the latest one I've come up with, but I'm still not entirely satisfied with it. Can someone ...

Having trouble building a VueJS project that relies on webpack after deleting the node_modules folder

Recently, I encountered a problem with my web project and attempted to delete the node_modules folder. However, after reinstalling it from scratch, I'm unable to successfully build the project, whether for development or production. Running npm run de ...

Can NPM Dependencies Be Stored in a Folder Inside a Git Repository?

Is there a way for NPM to install dependencies using a Git URL that points to a specific sub-folder within the repository? I searched through the documentation but couldn't find a clear answer. I am aware of how to set up a Git repository to act as a ...

The deserializeUser function in PassportJS is being ignored

My setup involves using Passport to authenticate users stored in mongodb. Everything seems to be working fine with authentication, including successful and failed login attempts as well as setting session variables. However, I am facing an issue where Pass ...

Exploring methods for efficiently handling extensive XLSX files in a Node.js environment

Currently, I am utilizing the ts-xlsx library on the server side to read data. The process involves reading data from the frontend as a byte array using file-reader and then sending this byte array to a library to process the data. However, in cases where ...

Guide on setting up @types from an NPM module containing the "@" symbol in its title

Installing the node package is easy npm install @gamestdio/timer --save But when attempting to add the corresponding types npm install @types/@gamestdio/timer --save An error occurs Invalid package name "@types/": name can only include URL-friendly ch ...

What is the process for creating the token?

I've encountered an issue when generating a token while creating a user account. Despite my efforts, I keep getting an empty set. What could be causing this problem? Could there be an error in the syntax? Take a look at the controller file: import m ...

The function Page.evaluate() will not run within a Promise sequence

Recently embarked on my journey with Puppeteer. Struggling to extract data from a webpage as the evaluate method seems to be malfunctioning. var Browser var Page var Result puppeteer.launch() .then(function (browser) { console.log('Initialized ...

Encountering an issue while setting up a Next.js project, I am struggling to find a solution despite trying various methods

I attempted to install Next.js, and even updated my npm version in order to create a new React project with the latest Next.js. However, I kept encountering the same error. Aborting installation. Unexpected error. Please report it as a bug: Error: spawn ...

Converting JSON-style data into a string with the power of node mysql

Just a quick note - I'm a total newbie in the world of web development, so I might be missing an obvious solution here. My challenge is to insert a dataset into a MySQL database using nodejs/expressjs/mysql. I've managed to establish a connecti ...

How can Next JS automatically route users based on their IP address?

Currently, I am using express and the following method within app.get('/anyPath') to identify the IP address of the client: var ip = req.headers['x-real-ip'] || req.connection.remoteAddress if (ip.substr(0, 7) == "::ffff:") { ...

Issues with triggering the success block in AngularJS and Node.js Express when using $http.get

As a beginner in the world of AngularJS and Node.js, I'm facing an issue with my $http.get method. The problem is that the success callback block does not get executed when the request is successful, whereas the error callback works just fine when the ...

Encountering the following error message: "MongoServerError - E11000 duplicate key error on collection: test.users, index: email_1. Duplicate key found: {email: null}"

I'm a student working on creating a login authentication API using Node, Express, and MongoDB. My issue is that I can't add multiple users when signing up. Despite searching through numerous threads on this website, I haven't found a solutio ...

Experiencing an ER_CON_COUNT_ERROR is common when the default max pool of Knex.js is exceeded due to an overwhelming

We currently have 30 DigitalOcean droplets, each dedicated to a web CRM user. They all share the same MySQL database using knex.js. However, with a few additional users, we are encountering some errors: "ER_CON_COUNT_ERROR: Too many connections" ...