NPM has surprisingly opted for an outdated Node version

Upon running node -v on my Linux system, the output is as expected with v16.7.0 due to the binaries installed on my PATH. However, when a scripts element in my package.json calls node -v, it inexplicably prints v9.11.2. What could be causing this discrepancy?

The issue came to light when it became apparent that the older version was being used for executing a script missing features needed. This minimal example of using -v at least sheds some light on the problem.

Running which or whereis for node or npm shows the correct directory where the binaries are located within my PATH. After scouring other directories in PATH, no node/npm executables were found.

Outputting echo "$NODE_PATH", with or without quotes, results in a blank line.

No answers seem to be present in $HOME/.npmrc.

The mystery remains: from where exactly is Node v9 fetching its references, and what steps can be taken to ensure that calling node from an npm script triggers a more modern version?

Answer №1

The user's global node_modules/.bin directory is prioritized over the system path, meaning any installations in that directory will take precedence. If you try to uninstall using npm uninstall -g node, it may not fully remove the package and manual intervention might be necessary.

You can determine this location by running the whereis node command within an npm script instead of simply checking with node -v.

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

Utilizing Node gRPC for seamless transmission of server metadata to clients without any issues

When working from the client side, adding metadata for the server is a simple process: const meta = new grpc.Metadata(); meta.add('xyz', 'okay'); stub.service.Rpc(request, meta, (err, response) => { }); To access the above on the ...

Capture (and perhaps reject) incoming web socket upgrade requests

I am facing a challenge with my Node.js server as I send a web socket upgrade request. The Authorization header in the request contains login information that needs to be validated against a database entry before allowing the connection. To prevent potenti ...

Installing NPM modules globally requires the use of sudo to do so successfully

After reinstalling Ubuntu 12.04 LTS, I took the following steps: Firstly, I installed Node using the package manager with the provided script below: sudo apt-get update sudo apt-get install python-software-properties python g++ make sudo add-apt-rep ...

There seems to be an issue with the pastebin api createPasteFromFile method as it is showing an error of 'create

I'm currently working on a logging system using node for a twitch chat. The idea is that when you type "!logs user" in the chat, it should upload the corresponding user.txt file to pastebin and provide a link to it in the chat. For this project, I am ...

regex execution and testing exhibiting inconsistent behavior

The regex I am using has some named groups and it seems to match perfectly fine when tested in isolation, but for some reason, it does not work as expected within my running application environment. Below is the regex code that works everywhere except in ...

NodeJs took an unexpected turn

I’m encountering an issue with an http request to forecast.io. When I make a normal request using $.ajax, everything works fine. However, when I try using the ajax-request module, I receive the following output: SyntaxError: Unexpected token u in JSON at ...

Looking for ways to speed up npm installation on TeamCity?

Having trouble using TeamCity to build and deploy my Ionic program. Every time, TeamCity needs to install all npm modules again. I attempted to backup the node_modules folder using PowerShell, but unfortunately TeamCity does not allow the use of remove-it ...

What is the best way to change a Buffer array into hexadecimal format?

After making a call to one of my API endpoints, I am receiving a Buffer array in a JSON object. My goal is to convert this array into a more user-friendly format such as hex so that I can easily compare them. Below is a snippet of the current object struct ...

Puppeteer exhibiting unexpected behavior compared to the Developer Console

My goal is to extract the title of the page using Puppeteer from the following URL: Here's the code snippet I am working with: (async () => { const browser = await puppet.launch({ headless: true }); const page = a ...

Having trouble installing an npm package with your Python script?

Here is the Python code I am struggling with: import subprocess subprocess.Popen(["npm", "install", "express"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) Unfortunately, this code isn't working as exp ...

Develop a cross-platform application using webpack for both web browsers and Node.js

I'm currently developing my first module, and the code is almost identical for both browser and node.js versions. The only variance lies in the use of XmlHttpRequest for the browser and the http module for node.js. Here's a sample code snippet t ...

Leveraging boostrap.less from Twitter in an Express project

After following a guide on web development, I attempted to set up Twitter's bootstrap.less using Node 0.6.12 and Express 2.5.8: Here is my app configuration: app.use(express.compiler({src: publicDir, enable: ['less']})); app.use(express.st ...

Encountering issue: LineChart is not recognized as a constructor, resulting in failure to display chart on webpage

I am struggling with displaying a chart in my HTML file that should show the details of a specific process from the past few minutes. Whenever I try to initialize the chart using google.charts.load('current', {'packages':['line&apo ...

Tips on ensuring a readable stream is properly closed

I have a question regarding handling readable streams from a library I am utilizing. How can I properly close any readable stream once all the data has been consumed? Although I see the `end` event, I never receive the `close` event. I have tried using ` ...

Node.js: Deciding between res.render and res.redirect in express-session

On my website, I have a login page and a myservices page. Once a user logs in, they should be redirected to the myservices page where their username is displayed. In the login.js file, the following code is used: req.session.user = "abc"; res.redirect(&a ...

The name 'Queue' cannot be located in Typescript, error code ts(2304)

I'm currently trying to create a private variable of type InnerItem, but I keep encountering the following error: Error: Cannot find name 'Queue'.ts(2304) private savedItems: Queue<InnerItem> = new Queue<InnerItem>(20); Could ...

Error: The function "parse" is not defined

After installing the Font Awesome dependencies for my app and attempting to run npm start to test it, I encountered a troublesome error that has proven to be quite challenging to solve. $ npm start > <a href="/cdn-cgi/l/email-protection" class="__cf ...

Issue: Unable to locate task named "watch:sass" when running the NPM Start command in the terminal

Currently, I am immersed in a CSS Grid tutorial and have encountered an issue that is unrelated to CSS Grids but rather with my package.json file. Following the instructions of the instructor meticulously, I executed 'npm start' only to be met wi ...

Utilizing Docusign's Template for Seamless Embedded Signing

Looking for guidance on how recipients can sign through a nodejs application using a template. I am currently utilizing the docusign node sdk and would prefer to embed the signing process directly into the application (Embedded Signing) via API, rather t ...

Using a REST API to make a POST request that calls a function and passes

Within my index.js file, the following code is implemented: app.post("/token", function (req, res) { var token = req.body createToken(token); }); This functionality is then exported by token.js const createToken = (token) = (req, res) => ...