Is it me or yarn? - node.js

apt works great for me. Rarely a problem and always easy to fix.
conda works great for me. Rarely a problem and always easy to fix.
I can't seem to get yarn to work...ever. Always some strange problem with node version or gyp libraries. Even when I get all of that fixed I get lots of warnings and then errors like
error An unexpected error occurred: "ENOENT: no such file or directory, lstat '/home/balter/.cache/yarn/v4/npm-tar-fs-1.16.3-966a628841da2c4010406a82167cbd5e0c72d509/node_modules/tar-fs/test/fixtures/a/hello.txt'".
Turns out if I run yarn install again there is a different file it can't find. Just for fun, I did
for i in {1..100}; do yarn install; done
Yup it errored on a different file every time, but never did "work."
Is it me, or is yarn just really fragile? If I want to install a package from github and the install instructions use yarn, is there a way around using yarn?
Also, no tag for "yarn"

I had the same problem in WSL one time and fix that using yarn cache clean

I was getting this same frustrating and hard to debug error. The problem in my case seemed to be yarn workspace behaviour caused by different versions of the same dependency in different packages (specifically ava versions 2 and 3). Only once I'd upgraded all occurrences of ava to their latest did I stop getting this error.

I was running into this same problem on Windows 10. I tried yarn cache clen because I saw that the tar-fs dependency was corrupted on disk going into the cache path (C://...AppData/Local/Yarn/Cache/npm-tar-fs...).
I saw that using yarn cache clean was deleting all cache files except for this one that was corrupted. I also tried deleting it manually and Windows wasn't allowing it.
So the solution was going into cmd and deleting it from there using the command DEL /F /Q /A <File Path>.
After that I ran yarn install again and it worked!

Related

Bundling errors after updating an npm package in React Native app

I'm building a React Native app which, at this point, doesn't have too many dependencies.
Every time I update an outdated npm package, I am GUARANTEED to run into bundling errors. It could be any package. I then spend hours trying different ways to clear npm cache, project cache, etc.
Does anyone else have this issue? Is there a "standard" set of commands I should run after upgrading ANY npm package? This is extremely frustrating!
This screen shot shows today's flavor of the issue:
BTW, I'm on Windows 10, using VS Code. My React Native version is 0.63.1, Node version is 14.7.0 and npm version is 6.14.7
UPDATE:
After a couple of hours of messing around and removing node_modules folder several times and issuing the following commands a few times, it's now started to work. Unfortunately, I can't put my finger on what fixed it. As I said, I did the same things a few times.
Here are the steps I repeated a few times -- though once should be enough:
Deleted the node_modules folder
In root folder, I ran npm cache clean --force
I then reinstalled all npm packages by running npm i
Went into cd android folder and ran ./gradlew clean
Then in project root, I ran npm start -- --reset-cache
Unfortunately, doing this the first time didn't fix the issue. It looks like I have to waste a couple of hours for things to get back to normal! Any idea how to make this problem go away for good?
I think this error is that you have not start the metro bundle. Try react-native start and then re-run the app

Problems installing the expo-cli

I've been trying for the past few hours to install the expo-cli. Half way through installation I keep getting this error:
tarball data for #expo/traveling-fastlane-darwin#1.10.0 (sha512-XXX) seems to be corrupted. Trying one more time.
After a really long time it crashes without expo-cli being installed.
I thought it could be a problem with Node.js. So I reinstalled Node.js and deleted every npm folder I could find. Furthermore cleared the cache with:
npm cache clear --force
Nothing works... Anybody has an idea why I keep getting this error?
Looks like a common windows issue. Have you tried version 3.7.1?
npm i -g expo-cli#3.7.1
Otherwise try to install the linux subsystem and use the linux bash.

React-Native stuck at Loading dependency graph done. No errors

I have a problem with my app, after running react-native run-android, the procees stop with blank page app at get stuck at loading dependency graph done... nothing happens. Everything was ok and suddenly not work anymore.
I tried everything i found on the internet... still not working. Any ideas?
package.json
This is what i get..
Probably, it might be an issue with watchman. Please try to close all terminals and emulator, clean the project and give the build. It did worked with me when i came across the same situation.
When you’re unable to load a bundle, look at the packager logs or the error message displayed in the Expo client to see if it’s related to the packager. If so, you should try clearing the packager’s state to reduce the chance the bug is related to a stale cache or corrupt process.
These instructions are for macOS and Linux, but the general ideas apply to Windows as well.
Stop XDE/exp, which should also stop the packager. Check your list of running processes to ensure these processes are not running.
Delete node_modules in your project
If your project depends on other local projects (e.g. has a file:
URI in its dependencies), clear those local project’s node_modules
directories too for good measure even though it’s probably
unnecessary.
Clear your Yarn or npm cache, depending on which you’re using, with
yarn cache clean or npm cache clean
Run yarn or npm i to install your dependencies again
Run watchman watch-del-all to clear Watchman’s state
Kill the watchman daemon process
Delete the packager’s cache directory with rm -fr $TMPDIR/metro*
Start XDE or exp
With exp, run exp r -c for good measure
And just to be sure, force quit the Expo client on your phone or simulator and re-open it.
None of the above answers worked for me. I had this issue after transferring my data from my old mac to my new one. It turned out that the brew installed python was not properly transferred. So, basically I uninstalled and reinstalled watchman.
brew uninstall watchman python
brew install watchman
I then restarted the packager, and I was ready to go.

cannot uninstall node and npm completely on high sierra

I recently installed Node on my MacBook running High Sierra 10.13 using the .pkg file supplied on their website.
After a few hours of experimenting with installing other packages and writing scripts, I decided I would like to uninstall both Node and NPM to get a fresh start.
I tried all of the top answers from this thread, but to my dismay, after having followed all instructions, and repeated all steps many times, terminal would still recognise the Node and NPM versions.
I ended up running a bash script through terminal which I found on the same thread, which ended up doing nothing but downgrading my current version of Node to 0.10.8 - making it a lot more difficult to delete in the long run.
I've re-done all of the steps from the aforementioned thread with no avail, and terminal still stating that it has version 0.10.8 (and NPM just completely not working at all)
Currently at my last stance of what to do, so hopefully someone on here can help me with my problem.
Cheers.
After searching through Google and StackOverflow for hours, I finally came up with a solution to the problem on my own.
Running the type command within terminal against node, I got this returned:
:~ myusername$ type node
node is /Users/myusername/.nvm/v0.10.48/bin/node
Subsequently, after deleting that folder, Node appears to be completely removed from my system.
I have since made sure that I have deleted all node and node_module folders that I could find within /usr/ to make sure - and I would suggest that anyone attempting this also do the same.
Try to run the following command
brew uninstall node
After the above command, you need to scan manually for node_modules if exists. Try following.
grep -irl "node_modules/node"
sudo rm -rf result_from_above_command
rm -rf ~/.npm
I hope this will remove all the node and it's components. As I have done like this, once before.
Thank you.

Cannot find module dtrace-provider

I have a simple nodejs application that is throwing "Cannot find module './build/Release/DTraceProviderBindings'". I look it up online and it looks like that a lot of people are having the same problem when using restify on windows (which is my case, I'm using restify on windows 10). Apparently, dtrace-provider is a optional module for restify and there is no version of it for windows. So, what I tried so far:
Update node to v6.2.0;
Uninstall all modules and run npm install --no-optional;
Uninstall only restify and run npm install restify --no-optional;
And my most desperate move npm install dtrace-provider.
Everything I tried where found on github issues, I've seen same error on OSX users with other modules. Not sure what else to try.
Note: This exception does not stop my application, not even prints the error on the console, I just notice that this was happening using the debugger, in other words, my application runs fine, but this keeps happening on the background.
List of other modules I'm using:
"dependencies": {
"restify": "latest",
"request": ">=2.11.1",
"cheerio": ">=0.10.0",
"xml2js": ">=0.2.0",
"botbuilder": "^0.11.1",
"applicationinsights": "latest"
}
This worked for me after switching to Node 6.1 (and when re-installing node modules didn't work):
Install and save dtrace-provider
$ npm install dtrace-provider --save
Delete 'node_modules' folder
Re-install node modules
$ npm install
I found this thread before combining your attempts with another solution on the Github project issues for restify (https://github.com/restify/node-restify/issues/1093) and simplified best as possible.
I recently ran into this error as well on node 6.11.1.
I ran npm rebuild dtrace-provider and that resolved the problem.
The restify team followed an approach of trying to load the module by requiring it on a try/catch block. You should just ignore the exception.
I had success with the following (elaborate) sequence:
Adjust my path to not have spaces
rm -rf node_modules
rm -rf ~/Library/Caches/node-gyp/
npm cache clean --force
V=1 npm install -S dtrace-provider#0.8.8 --python=python2.7 (repeat this step, resolving as you go, until the install is completely successful … if it fails, check the version - I had rogue dtrace-provider#0.6.0 building at one point)
npm install
At this point everything should have installed cleanly, and I was congratulating myself on a job well done. Then I executed my code and still got the DTraceProviderBindings error. The cause was nested dependencies with the wrong version of dtrace-provider (especially bunyan).
To confirm, do npm list | grep dtrace -B6.
If there's anything lower than 0.8.8, edit package-lock.json, following the method in How do I override nested NPM dependency versions?. Replace requires with dependencies for dtrace-provider and update the version.
Back round to get everything clean: rm -rf node_modules
Then, again, npm install --python=python2.7
I had to iterate round npm list a few times because I thought I'd caught everything and I hadn't.
The key points were to use the required version of python, have a unix-friendly path, and hunt down all nested dependencies. The python version issues gave a big messy error, the space issue gave a much more missable error.
I know this is an old issue but I wanted to comment on it in case anyone else has the same issue I had.
My issue was caused by having parentheses in my path.
/users/karlgroves/Dropbox (Personal)/foo/bar/bat/project...
Moving the project to a path without the parens worked for me.
You'll need to wipe out node_modules and reinstall again.
I recently ran into this error as well on node v8.8.1
as #Derek mentioned, I ran npm rebuild dtrace-provider and that resolved the problem.
tl;dr; dtrace-provider utilized node-gyp which required python version >= 2.5 and NOT 3.5
I had this issue on OSX and found a post that showed using environment variable
V=/Users/your_user/your_project npm i dtrace-provider
This let me know that there was a dependency on node-gyp that was failing to build...Once I knew the issue was with this module was able to focus my attention at troubleshooting node-gyp.
This led to some log output indicating that my python version 3.5 was unsupported and it required version >= 2.5.
Went and downloaded python 2.7.x and checked /usr/bin/python 2.7.x to ensure it was there. Uninstalled the node module that was ultimately requiring this module, then used npm cache clean then reinstalled the module and this time it appeared to pick up the right python version to be able to build.
Hope this helps someone =)
I have tried many suggestions but get the same error again.
Finally, I found the correct way to solve this question.
Go the node.js website and download the latest version of node.js pkg.
After installed, reinstall your software, everything will be ok.
i managed to get this working by running this command
npm install --python=python2.7

Resources