Replit: Package operation failed while installing npm package

I have to run ‘npm run dev’ followed by downloading NodeJS everytime I want the repl to run. And it stops working again after a while, saying npm is not found. I tried installing npm through the side bar, but get the error

Replit: Updating package configuration

→ npm install npm
exec: “npm”: executable file not found in $PATH

Replit: Package operation failed.

Hi @asteria thanks for your message.

Can I ask why you aren’t using the node.js template to make your project? You shouldn’t need to install this every time you want the Repl to run.

If you could try recreating the project using a new Repl with node.js template and let me know if this fixes the issue. Thank you.

I had a closer look after forking your Repl, the replit.nix file has some very strange things in it.

Firstly there were multiple copies of dependencies. This might have been due to the fact you were installing node.js multiple times.

I also spotted some python code in the dependencies (print and import os) which caused an error on run. I tidied mine up to look like this:

{ pkgs }: {
	deps = [

Once I ran the code it launched with no issue. Could you try replacing your replit.nix file with the one above before rebuilding, just in case?

This works! But I did actually use a template – the NextJS one

npm trying to acess protected virtual machine locations when install some packages, and is not allowed, or when acess drivers on virtual machine

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.