lerna bootstrap fails with "no such file or directory" - node.js

Trying to run the command
lerna bootstrap --hoist
On an application I cloned from GitHub. The instructions are to
Clone
Then run lerna bootstrap --hoist
However, when running the lerna bootstrap --hoist command, each time it fails and I get an error exactly like this but the node module changes each time:
npm ERR! code ENOENT
npm ERR! syscall rename
npm ERR! path /data/packages/nodes-base/node_modules/arr-filter
npm ERR! dest /data/packages/nodes-base/node_modules/.arr-filter.DELETE
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, rename '/data/packages/nodes-base/node_modules/arr-filter' -> '/data/packages/nodes-base/node_modules/.arr-filter.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
I am doing this on a Docker linux container. My frustration lies in the fact that the same setup worked on my previous laptop, but doesn't on this new one I have. My colleague tried this on his Ubuntu machine and it works with no issues.

I don't know the reason, but what allowed it to work was switching to the WSL mode on Docker, instead of having it use Hyper-V.

Related

NextJS not running on MacOS even after installing modules

So I've just created a NextJS project using create-next-app which went smoothly as expected. Then ran npm i just to be sure and saw all modules installed into node_modules
When I try to run npm run dev to start my nextjs app. it just says
sh: next: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! test#0.1.0 dev: `next dev`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the test#0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/john.v.n.pakson/.npm/_logs/2022-10-06T08_01_29_725Z-debug.log
It seems like npm is not detecting the node_modules i have installed.
Not sure if this is a mac or a zsh issue.
I'm using node version 12.22.12
Upgraded to 16.17.1 and still see the same error
> test#0.1.0 dev
> next dev
/var/folders/6y/xtlzp4z16dj0stxnqx8znj8w0000gn/T/dev-01c08137.sh: line 1: next: command not found
Okay I figured it out. It was caused by my file path on macos. My project was on a folder called Project/Test which might have confused zsh or mac. This in turn caused npm to not be able to find the correct scripts on my node_modules
When I moved my project to another folder I was already able to run npm run dev properly.
Cheers!

Windows 11 - npm ERR! errno -4058 - code ENOENT bash

Got this very annoying NPM issue out of nowhere, though I must say I had a few weeks break from playing with my project.
Actual version of core-js.
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\User1\Documents\project11\node_modules\**#angular\cli**
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
This npm ERR! errno -4058 seems to be rather common issue, but I've found no success and am getting a bit worried, I've tried all possible solutions I've found online (below)
Delete package-lock + node modules + npm cache and then run npm install
Use yarn instead of NPM (installation succeeds but can't run project)
Reinstall node and npm completely
Test with different (newest) npm & node versions
Test building only production version
Restart computer
Close all vscode applications etc. that could use npm
Run cmd as admin
Check windows defender if it could block npm
Make sure system32 is correctly set in env. variables
Hox, the erro says angular-cli, but if I somehow manage to get through that, it will just complain about the next library
Edit: Workaround for me seems to be to run npm in git-bash
For some reason I can't use powershell nor CMD anymore to run NPM, but that's not a big issue.
Funny. Before I posted this question, I already had spent well over 5 hours testing everything I found online. Immediately after posting this question, I, just for the sake of it, tested running npm install in "git-bash".
And.. it worked, so if somebody else is having issues with this, try running npm install in git bash https://gitforwindows.org/ instead
And of course you can try the things I tried above

How can I fix npm error running npm run build?

When I run npm run build, I had this error and I couldn't fix it reading all articles on github and same quest-s on stack:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\Користувач\Desktop\test/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Користувач\Desktop\test\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Користувач\AppData\Local\npm-cache\_logs\2022-02-06T18_36_44_973Z-debug-0.log
Hi you are trying to run the build command in non node project please check whether you are in correct directory or not, if not please initialize the project by running npm init
ensure you're in the correct directory. You need to cd into the right directory before running the command.
If you want to make sure package.json is there in the directory, run
ls | grep package.json
if this doesn't show the file, then either you're in the wrong directory or you might have deleted package.json in which case you might have to recreate it, or bring it back from version control.

npm run serve failed

When I try to run "npm run serve" in my terminal on my Mac. I get following error message. It works fine for a couple a hours ago, but not now. can anyone help me?
npm ERR! syscall open
npm ERR! path /Users/MYNAME/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/MYNAME/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/MYNAME/.npm/_logs/2020-09-03T12_46_01_362Z-debug.log
First check on your filesystem if the file EXISTS.
for a new project, you always need to create a package.json, running
npm init
will create a package.json for you in the current directory.
if you want to instantly create a package.jsn using defaults, run
npm init -y
for more understanding refer this npm guide
If you say that everything worked before, then you are running this script in the wrong folder and npm cannot find package.json.
no such file or directory, open '/Users/MYNAME/package.json'
Use the correct folder.

React Application npm start is giving an error

I am trying to run my React app in the local environment and keep getting the following error
PS npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Documents\business-website-react-master\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\\Documents\business-website-react-master\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\\_logs\2020-02-22T20_12_59_502Z-debug.log
Here is what the folder directory looks like as well.
the package.json file is still there so i don't understand why the file cannot be located.
Thank you in advance!
As the error message states, npm does not find package.json file. The reason in your case is that the file is located in the src folder. Once you move the file into the root - where you tried to run earlier - and run npm start then it should be just starting fine.
If the node_modules folder is also missing - which is containing all the installed dependencies to run your project - then you need to run first npm install which will take all the dependencies from package.json and install them.
I hope that helps!

Resources