I can't use "create-react-app" ("This is related to npm not being able to find a file.") - node.js

I tried every single thing I've found, but I just can't run create-react-app. I tried to uninstall node and install again, use yarn, clean cache, create with "npm init ..." but nothing works.
Microsoft Windows [versão 10.0.19043.1889]
(c) Microsoft Corporation. Todos os direitos reservados.
C:\Program Files (x86)\Windows Resource Kits\Tools>cd C:\Users\user\meu_app
C:\Users\user\meu_app>node -v
v16.17.0
C:\Users\user\meu_app>npm -v
8.18.0
C:\Users\user\meu_app>npx create-react-app myapp
npm ERR! code ENOENT
npm ERR! syscall spawn C:\Users\user
npm ERR! path C:\Users\user\meu_app
npm ERR! errno -4058
npm ERR! enoent spawn C:\Users\user ENOENT
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\user\AppData\Local\npm-cache\_logs\2022-09-02T19_06_17_314Z-debug-0.log

I have never seen this issue before. npx is distributed with npm 5.2+, so that shouldn't be the issue. It seems your issue is similar to this one Can't install any NPM package, error 4058
Try these steps:
Delete package-lock.json and run NPM again (probably can skip this one if it does not pertain to your issue)
Ensure no other processes of node.js are running (check task manager)
If you are using visual studio code, close it and try running npm install again.
If all else fails, restart your computer.
See thread here: https://github.com/npm/npm/issues/17444
Let me know if that helps; otherwise, I will keep looking.

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!

how to fix npm error in Mac in visual studio code

How do I fix this error?
USER#Bahus-MacBook-Air metaplex-master % npm --version
8\.5.2
USER#Bahus-MacBook-Air metaplex-master % npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/USER/Desktop/solana devnet/metaplex-master/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/USER/Desktop/solana devnet/metaplex-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! /Users/USER/.npm/\_logs/2022-03-24T13_07_17_630Z-debug-0.log
How do I fix this npm installation error in visual studio code in Mac?
The error message says that the path where you are executing npm i command doesn't have package.json file.
Make sure to change the path to the place where the package.json file is located.
I'm assuming you are trying this project https://github.com/metaplex-foundation/metaplex
And you are probably running npm install in the main directory. But if you read the instalation documentation which you definitely should, then you would see cd metaplex/js which means you need to run npm install within the ./js folder since that's where the package.json is, which is required by npm install command.

Unable to update npm from 6.14.8 to 7.3; deleting npm.cmd, npx.cmd, and npm leads to more errors

I've been attempting to update my npm globally using the npm install -g npm command in Git Bash to keep it current with Angular 11 and Node.js version 15.5.0. I receive the following error:
npm ERR! code EEXIST
npm ERR! path C:\Program Files\nodejs\npm.cmd
npm ERR! Refusing to delete C:\Program Files\nodejs\npm.cmd: is outside C:\Program Files\nodejs\node_modules\npm and not a link
npm ERR! File exists: C:\Program Files\nodejs\npm.cmd
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
I deleted the file from nodejs and attempted to install again, but received another error about the npx.cmd. I deleted that file, attempt installation, and received an error about the npm file.
npm ERR! code EEXIST
npm ERR! path C:\Program Files\nodejs\npx.cmd
npm ERR! Refusing to delete C:\Program Files\nodejs\npx.cmd: is outside C:\Program Files\nodejs\node_modules\npm and not a link
npm ERR! File exists: C:\Program Files\nodejs\npx.cmd
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! code EEXIST
npm ERR! path C:\Program Files\nodejs\npm
npm ERR! Refusing to delete C:\Program Files\nodejs\npm: is outside C:\Program Files\nodejs\node_modules\npm and not a link
npm ERR! File exists: C:\Program Files\nodejs\npm
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
After deleting them and attempting to install npm again, Git Bash no longer finds npm. The installation never starts.
bash: /c/Program Files/nodejs/npm: No such file or directory
I tried to delete the npm file from my roaming folder in AppData, but received the following error:
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\Yoga 2 Mitchell\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\Yoga 2 Mitchell\AppData\Roaming\npm'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
I've also tried the following at different times:
Delete node_modules and reinstall npm
Used npm 7.3.0's Git repository to create a new npm file (?) (I will need to find the suggestion online again to clarify/provide more specifics)
Clean caches
Uninstall and reinstall Angular 11 CLI and Node.js (tried for both LTS and Current version)
Nothing has worked so far. The second method I tried in the above list was able to update it to 6.14.10, but this attempt returned errors that seemed to affect Angular. I reverted everything to the original state to be safe. Please let me know if I can clarify anything else regarding my issue.
I connected with another developer about the errors I've been receiving. The following approach was suggested, and it works for fixing the problem for LTS: How to completely remove node.js from Windows
The LTS version allowed me to update to npm's 6.14.11, but when I tried this approach to install the Current version, it stayed 6.14.11. Hopefully, this approach helps others who are experiencing similar errors.

NPM on new Mac with transferred files from my previous linux system. Problem with npm start on VS CODE terminal

Hey people...transferred some working js files from old linux to my new macbook air. Upon trying to start my files with NPM start in the vs code terminal, I'm getting this error: (please help!)
Galias-MacBook-Air:react-nextagram Guy$ npm start
react-nextagram#0.1.0 start /Users/Guy/Desktop/Next Academy/react-nextagram
react-scripts start
sh: /Users/Guy/Desktop/Next Academy/react-nextagram/node_modules/.bin/react-scripts: cannot execute binary file
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! react-nextagram#0.1.0 start: `react-scripts start`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the react-nextagram#0.1.0 start 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/Guy/.npm/_logs/2019-01-24T01_15_13_056Z-debug.log
Galias-MacBook-Air:react-nextagram Guy$
Me too. I migrate from Ubuntu 18.04 to OSX Catalina. This is how I solve :
Delete your node_modules and npm install or npm install -s
Problem is inside your node_modules
The problem here is that you have compiled dependencies. One or more of the packages you use on your application need to be compiled against the OS you are going to run them in. To fix this, you can try one of the options bellow:
This will rebuild everything against your current OS.
npm rebuild
Or
you can do a clean install.
rm -rf node_modules && npm install

I cannot create angular project with "ng new app_name". Get error -4058

When I execute the command ng new app-name I get error -4058.
When I run the same command opening cmd as administrator in the directory C: / Windows/system32 I have no problems when creating the project. But if I change the directory I have the same issue.
I suppose it must be a permissions problem but it is not solved by opening cmd as administrator.
The creation process is frozen in extract: rxjs: and after a long time I get the following error
npm ERR! path C:\Users\Usuario\proyectName\node_modules\#angular-devkit\build-optimizer\node_modules\typescript
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Usuario\proyectName\node_modules\#angular-devkit\build-optimizer\node_modules\typescript' -> 'C:\Users\Usuario\proyectName\node_modules\#angular-devkit\build-optimizer\node_modules.typescript.DELETE'
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\Usuario\AppData\Roaming\npm-cache_logs\2018-03-20T02_40_45_377Z-debug.log
Error: Package install failed, see above.
Package install failed, see above.
Npm version
5.7.1
Angular version
Angular CLI: 1.7.3
Node: 8.10.0
OS: win32 x64
Angular:
...
I was able to solve the problem by uninstalling completely angular/cli and node
Uninstalling angular/cli and nodejs as administrator.
Delete folders from% appdata% (npm, npm-cache)
delete "nodejs" folder from Programs and Files
Reboot
Reintall lastest version node (not as administrator)
Install angular/cli (not as administrator)

Resources