unable to npm link a directory - npm

I'm trying to npm link to a directory inside another project's node modules (as per this issue and workaround https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react where otherwise stuff doesn't work because a library I'm including also has a react)
What seems to be happening is even though I specify that the path has to have node_modules in side of it (see the first line for the input: sudo npm link ../../EicherDesignBuild/contractor-order-app/node_modules/react), somehow, npm link internally takes that part out (no such file or directory, open '/home/user/Documents/Dev/EicherDesignBuild/contractor-order-app/react/package.json')
(I have to do it with sudo, otherwise I'm getting a permissions error)
[user#work contractor-order-app]$ sudo npm link ../../EicherDesignBuild/contractor-order-app/node_modules/react
npm WARN tarball tarball data for react#file:react (null) seems to be corrupted. Trying again.
npm WARN tarball tarball data for react#file:react (null) seems to be corrupted. Trying again.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/user/Documents/Dev/EicherDesignBuild/contractor-order-app/react/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/user/Documents/Dev/EicherDesignBuild/contractor-order-app/react/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! /root/.npm/_logs/2022-07-16T19_24_44_703Z-debug-0.log
What is happening and why? How can I link this library?
npm version: 8.11.0
node version: v14.19.0

Related

npm publish looks for package.json at disk root

Current npm version: 8.19.2
Command npm publish --registry "https://some-private-registry.com" running from package home.
Produces the following error:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\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! <somewhere>
I tried passing current folder as argument, i.e. npm publish "C:\path-to-folder" --registry "https://some-private-registry.com" running from package home, but with no success - the error stays the same. npm prefix correctly returns current folder.
For some reason - which I cannot understand - publish searches for package.json at disk root. Which is also important, npm unpublsh and npm install work without any issue.
Debug log also doesn't provide any sufficient information except above error.
Is there anything I might miss which could be causing the problem?
Thanks!

i get error when i run sudo npm run serve

I was getting error when i was installing npm but it seemed to me that it run fine. I created default app and i tried sudo npm run serve but i get this error
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/00/00/00/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/00/00/00/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
I tried:`npm cache clear` & `sudo npm cache clear` and i get error starting with As of npm#5, the npm cache self-heals from corruption issues.
NPM VERSION 8.18.0
Fixed it, i needed to add package.json file to my app.

Error reading tmp file/directory when using NPM to include a GIT only package

I am trying to include the GIT package https://github.com/Denglo/bs5-autocomplete-vanillaJS.git into my (simple) project. This currently only has two other packages:
"dependencies": {
"bootstrap": "latest",
"bootstrap-icons": "latest"
}
Running a npm install with the above works without an issue, but when I run any of the following
npm install git+https://github.com/Denglo/bs5-autocomplete-vanillaJS.git
or
npm install https://github.com/Denglo/bs5-autocomplete-vanillaJS.git
or
npm install github:Denglo/bs5-autocomplete-vanillaJS
I get the following error:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path ~/.npm/_cacache/tmp/git-cloneHYQNgb/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '~/.npm/_cacache/tmp/git-cloneHYQNgb/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! ~/.npm/_logs/2022-07-22T09_37_33_747Z-debug-0.log
The ~/.npm/_cacache/tmp directory exists and the user has full access to it. The error log does not says the same as above. I also tried to manually add the line to the package.json, but that resulted in the same error.
Any ideas how I can solve this?

npm start isn't working in new React apps?

I've removed and reinstalled NPM and Node, still no fix. Here's the error code after I create-react-app and input npm start.
npm ERR! syscall open
npm ERR! path /Users/carriepresley/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/carriepresley/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent```
Use cd to the directory where package.json is located and then run the npm start command. This will work.

Not able to install apisauce in react-native project

I tried to install using the following code:
npm i apisauce --save
However, I got these errors:
npm WARN react-navigation-stack#2.8.2 requires a peer of
react-navigation#^4.1.1 but none is installed. You must install peer
dependencies yourself.
npm ERR! code ENOENT npm ERR! syscall rename npm ERR! path
F:\DoneWithIt\node_modules\follow-redirects\node_modules\debug npm
ERR! dest
F:\DoneWithIt\node_modules\follow-redirects\node_modules.debug.DELETE
npm ERR! errno -4058 npm ERR! enoent ENOENT: no such file or
directory, rename
'F:\DoneWithIt\node_modules\follow-redirects\node_modules\debug' ->
'F:\DoneWithIt\node_modules\follow-redirects\node_modules.debug.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\Ravi\AppData\Roaming\npm-cache_logs\2020-08-01T13_33_29_249Z-debug.log
I was stuck on this same issue today and I think I fixed it just now. I followed the suggestions of uninstalling nodejs (and the node_modules folder if that doesn't also get automatically removed with it), making sure that your nodejs folder is in the environment variables path.
The stackoverflow thread I referenced is: Fixing npm path in Windows 8 and 10