Struggling to update nodejs and npm on Raspbian running on Raspberry Pi 3

Currently, my Raspbian operating system is using Node.js v4.8.2 and I am struggling to upgrade it to the latest version. Despite following the solution provided in this post about npm command not working on Ubuntu, I have been unsuccessful. When attempting to run the command sudo apt-get install -y nodejs, I encountered the following error message:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libiw-dev : Depends: libiw30 (= 30~pre9-8) but 30~pre9-12 is to be installed
 nodejs : Conflicts: nodejs-legacy
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Another attempt was made by directly installing NPM through the command: sudo apt-get install npm. However, this resulted in the following message:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 [List of npm dependencies]
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

If anyone has any advice or solutions for this issue, I would greatly appreciate it. Thank you.

Answer №1

The issue arises from the following line:

nodejs : Conflicts: nodejs-legacy

To resolve this, it is recommended to uninstall all versions of node first.

(You can find further help and commands on raspberrypi.org's community page):

pi@raspberrypi:~ $  sudo su -
root@raspberrypi:~ # apt-get remove nodered -y
root@raspberrypi:~ # apt-get remove nodejs nodejs-legacy -y
root@raspberrypi:~ # apt-get remove npm  -y # if npm was previously installed

Ensure you are connected to the correct source.

root@raspberrypi:~ # curl -sL https://deb.nodesource.com/setup_5.x | sudo bash -

Proceed with the installation and verify the versions:

root@raspberrypi:~ # apt-get install nodejs -y
root@raspberrypi:~ # node -v
root@raspberrypi:~ # npm -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

Coordinating multiple API requests for optimal performance

I have a task where I need to retrieve data from two different API endpoints. Once both sets of data are fetched, I need to compare the information obtained from each source. I am familiar with fetching data from a single API endpoint and using a callback ...

What is the process for transitioning from imports with <script> tags to a module bundler system?

Currently, my project utilizes Angular without a task manager or dependency manager. All libraries are stored in the repository and included using <script> tags such as <script src="libs/angular/angular.min.js"></script>. In an effort to ...

What is the best way to incorporate a browser-specific vanilla JS library with dependencies into a React application?

Looking for a js/reactjs solution to interact with a janus webrtc gateway? I've decided to utilize the janus.js library from the meetecho janus-gateway sourcecode because: A: This library checks browser compatibility with Janus. B: The core team main ...

Serving HTML from NodeJS instead of JSON

I have implemented two middleware functions import { NextFunction, Request, Response } from 'express'; const notFoundHandler = (req: Request, res: Response, next: NextFunction) => { const error = new Error(`Page Not Found - ${req.originalUr ...

Recover files from the latest commit in Git, with files having no data inside them

Hello there! I encountered an issue with Git recently. I was attempting to clone a repository in order to push my project code, but I ran into an upstream error. I tried doing a git pull without success, then attempted to revert back to my initial commit ...

Setting up Twilio integration on a Parse Server deployed on Heroku

I am currently running a successful Parse Server on Heroku and am attempting to set up my Twilio cloud code. However, the moment I include var twilio = require('twilio')(twilioAccountSid, twilioAuthToken); in my main.js file, the application stop ...

NodeJS tutorial on obtaining the Instagram username and access token

How do I retrieve the username and access token after a user logs in using Instagram-passport for my app login? I'm having trouble accessing the 'profile' in the middleware section. //serialize user in the session passport.serializeUser(fun ...

How can I resolve the issue of opening a different URL when using npm start in a React app?

I am using gh-pages to publish my project I added "homepage": "https://Mohamed0Ahmed.github.io/portfolio" to package.json image.json When I type npm start, I expected the URL localhost:3000 to show up, but instead it shows localhost:3000/portfolio. When ...

Utilizing interface in NestJS for validating incoming request parameters

My goal is to utilize the interface provided by class-validator in order to validate a specific field in the incoming request body. Here's the interface structure: export enum Fields { Full_Stack_Dev = 'full stack dev', Frontend_Dev = &a ...

What is the best way to manage data types using express middleware?

In my Node.js project, I am utilizing Typescript. When working with Express middleware, there is often a need to transform the Request object. Unfortunately, with Typescript, it can be challenging to track how exactly the Request object was transformed. If ...

Utilizing Angular routes within a Node.js application deployed on Heroku

I've been working on deploying an AngularJS project to Heroku. The app functions perfectly fine locally and when using heroku local web. However, upon attempting to access it, I encounter the error TypeError: response.sendFile is not a function. Ser ...

Where do I begin on this uncharted journey of self-expression?

As I dive into learning node/express, I've acquired some books and followed online guides to get started. While I have created a basic app using the express command line tool with two routes defined in my app.js file, app.get('/', routes.in ...

Failure to read data and attempting to run a non-existent function

Currently, I am developing an API prototype and encountering an issue with reading data from Google Sheets using Express.js. The problem lies in fetching data from sheet 2 while it works fine for sheet 1. The package I use to read the data is available at: ...

Best practices for implementing "Event Sourcing" in the NestJS CQRS recipe

I've been exploring the best practices for implementing "Event Sourcing" with the NestJS CQRS recipe (https://docs.nestjs.com/recipes/cqrs). After spending time delving into the features of NestJS, I have found it to be a fantastic framework overall. ...

Remove any words that are not included in the specified list

Here is the code snippet to achieve the desired functionality: const { words } = require("../../json/words.json") const args = message.content.split(' ') const wordss = words.filter(m=> m.includes(args)) if(args > 1 || !wordss) { ...

Build a KeystoneJS website without using the generator-keystone tool

I have the complete collection of sources from a website built on KeystoneJS. I attempted to deploy it on my laptop (without using generator-keystone since all necessary files are already generated), but even after running npm install I encountered error ...

What techniques can I utilize to ensure Azure function generates JSON specifically for web browsers?

I have a functioning Azure function with the following code: module.exports = function(context, req) { // this is the complete source code, believe it or not context.done(null, {favoriteNumber: 3}); }; When I utilize a tool like Postman to access ...

Azure pipeline: Command Line error: Bash exited with code '1'

While attempting to run my Cypress test using Azure Pipeline, I encountered the following problem: YAML file: # To configure triggers for Azure CI see # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml ...

Issue with executing arbitrary code found in the underscore npm package

https://i.stack.imgur.com/VpE13.png Upon running npm install, a total of 1596 vulnerabilities were detected (comprising of 20 low-risk, 51 moderate, and 1525 high-risk vulnerabilities). The suggested course of action is to execute npm audit fix to address ...

Interested in uploading numerous images using express-fileupload

I am looking to improve my image upload functionality by allowing multiple images to be uploaded in a single input field without limiting the number of uploads. Below is the current code snippet that handles individual image uploads: router.post('/a ...