I cannot use Websocket package on NestJS - javascript

I'm trying to work with websockets on Nestjs, i install the dependencies
yarn add #nestjs/websockets #nestjs/platform-socket.io
I generated a example resource for the websockets
nest g res messagesWs --no-spec
Then this message shows up in my terminal
TypeError: this.metadataScanner.getAllMethodNames is not a function
This is a capture from the problem
What can i do?
PD: sorry for my bad english
I search for that function getAllMethodNames but i didn't get anything

I had the same problem. I solved it by downgrading a few versions.
From
"#nestjs/platform-socket.io": "9.3.6", "#nestjs/websockets": "9.3.6"
to
"#nestjs/platform-socket.io": "9.1.6", "#nestjs/websockets": "9.1.6"

It wokrs for me follow these steps:
remove node_modules folder
from package.json remove ^ before the version number
npm install

I back to v.
"#nestjs/platform-socket.io": "^7.6.15",
"#nestjs/websockets": "^7.6.15",
is working

Related

Vue-cli in [eslint] Cannot read properties of undefined (reading 'type') error

I installed Vue cli. I'm running the npm run serve command without writing any code yet, but unfortunately I'm getting below error. Is there anyone who can help?
The latest version of Node Js is installed. I thought it had something to do with Nodejs so I reinstalled nodejs but it didn't work.
I encountered the same issue today. Apparently it is caused by the newest version of esquery (1.4.1).
To fix this simply use an older version of esquery. You can do this via:
npm install --save-dev esquery#1.4.0
Be sure to not update or remove the ^ from "esquery": "^1.4.0" in package.json afterwards.
It's an esquery bug. Here is the relevant issue: https://github.com/estools/esquery/issues/135
If you are using yarn you can resolve a previous version of the problematic package (esquery) by putting this into packge.json. This will ignore the problematic version from one of the deps and use this explicit version.
"resolutions": {
"esquery": "1.4.0"
},
If you are using npm you can replace resolutions with overrides: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
How resolution works: https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/#toc-how-to-use-it
Thank you for your answers. After I asked my question here, I reinstalled the vue cli project, but this time I did it by installing the default settings. I had installed it using airnb settings in the previous installation. This is how I solved the problem.

DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at node_modules\postcss\package.json

Since I upgraded Node to version 16, I started noticing this when I build my Angular app.
DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at "...\node_modules\postcss\package.json".
Update this package.json to use a subpath pattern like "./*".
Is there a way to fix this without downgrading the Node version?
Solution:
Go to defined location C:\<xampp>\htdocs\<projName>\node_modules\tslib\package.json.
At exports field - replace this "./": "./" to "./": "./*".
I was using node 16 switched back to 14 and it started working.
Regarding the GitHub issue, this one is recurrent one:
https://github.com/postcss/postcss/issues/1455#issuecomment-872240742
An update of postcss should do the job.
I suffered from the same issue but into tslib package
I tried updating version by version till this version 2.4.0
now everything works correctly
Take a look at your package.json and check if you have --prod flag in the build script, if so update it for
--configuration production
That will solve the issue, too
The best way to fix this is to downgrade to a lower version of Node. But not doing a reinstall of Node.
Install NVM - Node version manager. That way you can have multiple versions of Node at the same time. For each project, you will be able to switch to a specific Node version you want. It can be found at https://github.com/coreybutler/nvm-windows
Try with this:
Go to node_modules\postcss\package.json
swap out "./": "./" with "./*": "./"

React Native console.error version mismatch [duplicate]

Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Getting the following message when I init a new project and then launch the Xcode emulator:
React-Native Version Mismatch
Javascript Version 0.50.1
Native version: 0.50.0
Make sure you have rebuilt the native code. ...
Does anyone know what is going on here and can help me?
This is what I've done with it:
Close all terminals and run build again.
You may forget to close nodejs terminal from another project, and they happen to have installed different react version.
So the code fetches from nodejs server conflicts with the native one.
In case you created your react-native app using create-react-native-app. You should have a app.json (expo). and a package.json file, check if the expo versions match and change accordingly. For example in my case the problem was that in the app.json file I had a 25.0.0 version for the expo sdkVersion attribute, I change that to 23.0.0 and everything worked.
package.json:
"dependencies": {
"expo": "^23.0.4",
"react": "16.0.0",
"react-native": "^0.50.4"
}
app.json:
{
"expo": {
"sdkVersion": "23.0.0" // before was 25.0.0
}
}
Just go to your android/app/build.gradle and then add to the dependencies section:
dependencies{
compile ("com.facebook.react:react-native:0.50.3") { force = true }
}
/// the react native version can be found in package.json
For Android developers who couldn't get it fixed by just closing and rebuilding, Manually uninstall the app on the emulator/device.
just force react native version in your android's app level gradle file, in the dependencies section.
compile ("com.facebook.react:react-native:0.52.0") { force = true }
worked for me
If you're running your React Native app through Expo, upgrading React Native is liable to cause this error (as noted at https://github.com/expo/expo/issues/923).
If that's your scenario, your options are:
Bump Expo (which is listed in your package.json) to a version that is compatible with your React Native version (if one exists, which may not be the case - judging by the linked issue, I figure that Expo support trails React Native releases).
Discard your changes, delete and reinstall your Node modules, Eject from Expo, and then (after checking that you can still run your app post-ejection) try your upgrade again.
I've never seen this error before, but whenever I can't get Xcode and React-Native to play well together, I do a couple of things. Check what version of Xcode I'm working with. If it needs to be updated, I update it. Then clearing watchman and the cache are the second place I go. I don't use the reset cache command. It always says that I need to verify the cache, so I skip that (you can do it though, I just get confused). I use rm -rf $TMPDIR/react-* to get rid of any cached builds. If that doesn't work, I try to build the app in Xcode, then work my way from there, to build it with react-native run-ios. With this error message, it seems you might start by trying to build it with Xcode. Hope that helps...let me know your progress with it. Good luck! (Also, you could update to RN 0.51 as another attempt to get your versions synced.)
I had this problem for the longest time and none of the above solutions helped. I was in the middle of upgrading react native in a create-react-native-app project until I found out that not all versions of Expo support the latest React Native.
Found this page linked in the documentation that shows which version combinations of React Native, React, and Expo are officially supported:
Source: https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md
Editing the app.json and package.json files to match the corresponding versions and running npm install got everything working again.
I am using a physical device, in my case this solved the problem:
Uninstall the app
lsof -i :8081
kill -9 PID
Rebuild the app (react-native run-android or react-native run-ios)
In your build.gradle file add the following
implementation ("com.facebook.react:react-native:0.51.0") {
force = true;
}
replace 0.51.0 with the version in your package.json
Try installing the dependencies again. That worked for me-
1.) yarn/npm install
2.) yarn/npm start --reset-cache
For me it was due to react-native version in dependency section of package.json file. It was:
"dependencies": {
"expo": "^27.0.1",
"react": "16.3.1",
"react-native": "~0.55.0"
}
I chaged it to:
"dependencies": {
"expo": "^27.0.1",
"react": "16.3.1",
"react-native": "0.52.0"
}
Now it works fine.
In my case installing a new virtual device helped. Now I am using 1 device per app.
It happens sometimes when you try to run without closing the node server, in which the previous app was running, so try restarting React.To do so, just run the following commands:
1. To kill current processes
killall node -9
2. To Start React Native
react-native start
3. Then Run android
react-native run-android
For my case I'm facing it on iOS, and I've tried to reset and clear all cache using below command but failed too, despite many comments saying that the root cause is there is react packager running somewhere accidentally, I've restarted my mac and the problem still remained.
watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start --reset-cache
The solution is, to delete the build folder # /ios/build, then execute react-native run-ios solved it
I have tried the solutions above but adding this to AndroidManifest.xml seems to fix it.
android:usesCleartextTraffic="true"
For others with the same problem on iOS with CocoaPods:
I tried all of the solutions above, without luck. I have some packages with native dependencies in my project, and some of those needed pod modules being installed. The problem was that React was specified in my Podfile, but the React pod didn't automatically get upgraded by using react-native-git-upgrade.
The fix is to upgrade all installed pods, by running cd ios && pod install.
Expo users - make sure your app.json sdk version and package.json expo version are (may be equal) compatible to each other.
The fix we did was to make sure the ANDROID_HOME and PATH variables were set up prior to the build.
First, run the below two commands then the build the app for the device.
export ANDROID_HOME=/Users/username/MyFiles/applications/androidsdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
This is working for me :
react-native start --reset-cache
I also had this issue using Expo and iOS Simulator. What worked for me was erasing the Simulator in Hardware > Erase All Content and Settings...
I have got the same issue while building my react native app for android and I did the following which worked for me.
The "JavaScript version 0.50.1" in the error console is the react-native version in your package.json file. Make sure it is the same version as "Native version 0.50.0" in the error console.
I have Updated the react-native version to the "Native Version 0.50.0" as prompted in the error console.
Rebuild the app react-native run-android.
Possible Fix:
Delete the package-lock.json
Run: watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/haste-map-react-native-packager-* && rm -rf node_modules/&& npm install
If the problem persists, try to execute the project directly from the Xcode
This worked for me.
In my case (NOT using expo & Android build)
package.json
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.2"
}
And app.json
{
"sdkVersion": "27"
}
resolved the issue
I was trying to build and run a React Native app from WebStorm and ran into this problem. The simple solution for me was:
watchman watch-del-all
On macOS, if watchman is not already installed, install it using Homebrew:
brew install watchman
In my case, I changed the expo version manually. I got the same issue because I forgot to update sdkVersion in app.json and babel-preset-expo in package.json
After that run: expo r -c to clear cache and start the app.
This Answer is Published in 2020,
Fix this Error in 3 steps:
First step: I changed the value of expo in package.json file to the latest supported version, according to expo documents(visit here).
Second step: I changed the value of sdkVersion in app.json file to the same value of expo in package.json.( equal number to last step).
Third step : I changed the value of react-native in package.json file to the same value of React Native Version , according to expo documents(visit here).
now your ready to go.
use npm install to install specified version of dependencies and then npm start to run the project
I got this classing when TypeScript type definitions mismatched.
E.G react-native at 0.61.5 in dependencies and #types/react-native at 0.60.0 in devDependencies.
As soon as I updated devDependencies it worked. Didn't have to restart anything.
edit your package.json for your javascript version
"react-native": "^0.50.1",
after run
npm install
For me, who is running with a monorepo, there was a hidden react-native version inside yarn.lock. It was not present in any package.json, but was never deleted.
I removed that particular react-native version from yarn.lock, and did a
yarn install
This cleaned out alot of old stuff and made sure that things was working fine.

Lite-server does not detect a `bs-config.json` or `bs-config.js` override file

I'm trying to run angular2 based first app. I followed angular2 steps. When i run command npm start then its giving following error in the terminal
Did not detect a bs-config.json or bs-config.js override file. Using lite-server defaults...
And also browser returning 404 error for index.html file (angular-project/app/index.html)
I check lite-server version is "lite-server#^2.2.0", and npm version 3.7.3, also i followed this accepted answer instructions but still facing same issue. Can anyone guide me how can fix it, I will appreciate. Thank You.
In Wrap up section different project structure than described in question. Please ensure that you have followed tutorial correctly.
I see you are running lite-server 2.2.0; anyone else looking for help with this error should make sure they are running lite-server 2.0 or greater as that's when config file support was introduced.
Also, it can throw this error if there is a problem executing the bs-config.js, so check your config file for anything that could be erroring (including but not limited to syntax errors). For me I had forgotten to install the http-proxy-middleware so lite-server errored when it tried to execute the first line of my bs-config.js, which was var proxy = require('http-proxy-midleware');. An npm install --save-dev http-proxy-middleware fixed this error for me.
HT: this github issue.
The reason that you have seen this warning message
Did not detect a bs-config.json or bs-config.js override file. Using lite-server defaults...
is probably that you have a definition in your package.json which describes what should happen once you trigger the npm start command, like:
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server -c bs-config.json\" ",
...
}
Therefore, in short you need to either provide the bs-config.json file with the desired browser-sync configuration or modify the the above command.
Moreover, angular2 has now its famous quick-start example on github.
I made this account specifically to second the answer made by Patrick on July 12th.
If your bs-config cannot be found it may be because you do not have the proper packages. In my case I had http-proxy-middleware, but was missing connect-history-api-fallback.
Make sure to check/install all the node packages used in your bs-config!

Which module in the MEAN stack collects mongodb dependencies?

>> Error: Cannot find module 'mongodb/lib/mongodb/connection/read_preference'
I am running a grunt server that can't find mongodb connection read_preference. As a result, my DOM was broken.
It sounds like it may be an issue with you package.json. Perhaps missing dependencies?
I have also seen this problem with mongoskin. If you are using that, try removing and reinstalling it.
After running npm install, you get node_modules directory populated with all dependencies. Here is what I got for default MEAN distribution:
$ find . -name "read_preference*" -print
./node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/read_preference.js
./node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/read_preference.js
And in package.json you can see following related entries:
"connect-mongo": "~0.4.1",
"mongoose": "~3.8.8",
Which are the modules you need to have to resolve that dependency.
Delete the node_modules directory and run npm install.

Categories

Resources