NestJS swagger-ui-express package is missing after deploy - swagger

I am using NestJS version 7.1.0 and serverless and creating api document uses nestjs swagger. In local it's worked like champ but after deploy got error.
swagger-ui-express package is missing
I see some issue here but still not resolve this issue.
https://github.com/nestjs/swagger/issues/277
This is my package.json
"dependencies": {
"#nestjs/common": "^7.1.0",
"#nestjs/core": "^7.1.0",
"#nestjs/passport": "^7.0.0",
"#nestjs/platform-express": "^7.0.7",
"#nestjs/swagger": "^4.5.8",
"aws-serverless-express-binary": "^1.0.1",
"class-transformer": "^0.2.3",
"class-validator": "^0.11.1",
"dayjs": "^1.8.24",
"dotenv": "^8.2.0",
"dynamodb-data-types": "^3.0.1",
"express": "^4.17.1",
"faker": "^4.1.0",
"jest": "^24.9.0",
"jwks-rsa": "^1.6.0",
"latinize": "^0.4.1",
"lodash": "^4.17.15",
"mime-types": "^2.1.26",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.0",
"rxjs": "^6.5.3",
"serverless-dynamodb-local": "^0.2.39",
"swagger-ui-express": "^4.1.4",
"tslint-loader": "^3.5.4",
"uuid": "^3.3.3",
"winston": "^3.2.1"
},
This is the config:
const options = new DocumentBuilder()
.setTitle("My APIs")
.setDescription("APIs description")
.setVersion("1.0")
.addTag("cats")
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup("api", app, document);
Any help!

My solution was to install express:
npm i express

I figured out the solutions, hope this help someone.
I add a fake endpoint to make sure swagger-ui-express not be removed after webpack ran.
if (event.path === "/api") {
event.path = "/api/";
} else if (event.path.includes("/swagger-ui")) {
event.path = event.path.replace("/swagger-ui", "/api/swagger-ui");
}
// Fake to keep swagger-ui-express work after deploy
if (event.path === "/fake-swagger-ui-express") {
swaggerUi.setup(null);
}

I had to run:
yarn install
to fix it.

Do you happen to be using yarn workspaces? I had the same problem just now, where locally everything worked but broke on our cluster.
If yes, then try adding this to the package.json of your API that is using the swagger module:
"workspaces": { "nohoist": ["swagger-ui-express"] }

Related

Missing node module error even though it's installed on a webdriverio/electron project. (ts-node)

I cannot figure out why I am getting the below error. I'm trying to set up webdriver-io for an existing electron project.
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\user\automation\product\src\product.client\
node_modules\ts-node\esm\transpile-only' imported from C:\Users\user\automation\product\src\product.client\
at new NodeError (node:internal/errors:372:5)
at finalizeResolution (node:internal/modules/esm/resolve:437:11)
at moduleResolve (node:internal/modules/esm/resolve:1009:10)
at defaultResolve (node:internal/modules/esm/resolve:1218:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
at ESMLoader.import (node:internal/modules/esm/loader:380:22)
at initializeLoader (node:internal/process/esm_loader:74:49)
at loadESM (node:internal/process/esm_loader:87:11)
at runMainESM (node:internal/modules/run_main:51:21) {
code: 'ERR_MODULE_NOT_FOUND'
}
I have been through the google desert. Of course I understand it's not found. But I can't figure out why it's not found? ts-node is installed. My package.json is below:
"devDependencies": {
"#types/chalk": "^2.2.0",
"#types/chart.js": "^2.9.34",
"#types/command-line-args": "^5.0.0",
"#types/execa": "^2.0.0",
"#types/node": "^14.6.0",
"#types/request": "^2.48.7",
"#typescript-eslint/eslint-plugin": "^2.18.0",
"#typescript-eslint/parser": "^2.18.0",
"#wdio/cli": "^8.3.3",
"#wdio/devtools-service": "^7.16.14",
"chalk": "^4.1.0",
"command-line-args": "^5.1.1",
"cross-env": "^7.0.2",
"electron-chromedriver": "^13.0.0",
"electron-packager": "^15.2.0",
"electron-wix-msi": "^3.2.0",
"eslint": "^6.8.0",
"eslint-plugin-import": "^2.20.0",
"execa": "^4.0.3",
"rimraf": "^3.0.2",
"ts-node": "^8.10.2",
"typescript": "^4.9.5",
"wdio-electron-service": "^3.5.1",
"webdriverio": "^7.7.4",
"yarn-run-all": "^3.1.1"
},
"dependencies": {
"chart.js": "2.9.4",
"electron": "^23.0.0",
"react-number-format": "^4.8.0"
}
}
Can any kind soul help me figure out what it's looking for or how to get around it? I'm very frustrated.
I don’t know if you already figured it out or not but I had the exact same error and it was a problem with the version of ts-node. So basically install a newer version of ts-node the one I installed was 10+. Hope this helps.

Invalid UIAccessibilitys 'tablist' error after installing react-native-vector-icons and running pod update on ios

I tried to install react-native-vector-icons and ran pod update and got the following error:
https://i.stack.imgur.com/FcVr0.jpg
now this pops up but I can build and run the app just fine.
is this ok? and how can I fix this ?
after this started happening I unlinked react-native-vector-icons and uninstalled it
but for some reason I still get this error, now I tried debugging it and it seems to have some thing to do with "#react-navigation/bottom-tabs" package.
my package.json:
},
"dependencies": {
"#eva-design/eva": "^2.1.1",
"#react-navigation/bottom-tabs": "^6.2.0",
"#react-navigation/native": "^6.0.8",
"#react-navigation/native-stack": "^6.5.0",
"#ui-kitten/components": "^5.1.1",
"#viro-community/react-viro": "^2.20.2",
"react": "17.0.2",
"react-native": "0.65.1",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "^3.11.1",
"react-native-svg": "^12.1.1",
"react-redux": "^7.2.6",
"redux": "^4.1.2",
"fsevents": "^2.3.2"
},
"devDependencies": {
"#babel/core": "^7.15.0",
"#babel/runtime": "^7.15.3",
"#react-native-community/eslint-config": "^3.0.0",
"babel-jest": "^27.0.6",
"eslint": "^7.32.0",
"jest": "^27.0.6",
"metro-react-native-babel-preset": "^0.66.2",
"react-native-codegen": "^0.0.7",
"react-test-renderer": "17.0.2"
},
"jest": {
"preset": "react-native"
}
would appreciate any help :)
I am facing the same issue. And I resolved it.
Go to node_modules -> #react-navigation -> bottom-tabs.
Find all accessibilityRole (in file BottomTabBar and BottomTabItem -> it is located at bottom-tabs/lib/commonjs/views and bottom-tabs/lib/module/views and bottom-tabs/src/views) and change it to none.
I changed accessibilityRole="tablist" to accessibilityRole="none"
And change accessibilityRole: Platform.select({ ios: 'button', default: 'tab' }) to accessibilityRole: Platform.select({ ios: 'button', default: 'none' })
This issue will be resolved. But when you install new package, you must do it again :))
This is definitely a problem with the built-in react-navigation tabs, but the issue went away when I created a custom tab bar.

when I run this NPX POD-INSTALL it gives me this COCOAPODS IS NOT SUPPORTED IN THIS PROJECT #ReactNative

Package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"#react-native-community/masked-view": "^0.1.10",
"#react-native-firebase/app": "^8.4.2",
"#react-navigation/native": "^5.6.1",
"#react-navigation/stack": "^5.6.2",
"expo": "^39.0.3",
"expo-ads-admob": "~8.3.0",
"expo-av": "~8.6.0",
"expo-image-picker": "~9.1.0",
"expo-status-bar": "^1.0.0",
"expo-web-browser": "~8.5.0",
"firebase": "7.9.0",
"lottie-react-native": "~2.6.1",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "^0.63.3",
"react-native-appearance": "~0.3.3",
"react-native-dark-mode": "^0.2.2",
"react-native-elements": "^2.3.2",
"react-native-gesture-handler": "^1.6.1",
"react-native-hide-show-password-input": "^1.1.0",
"react-native-material-ripple": "^0.9.1",
"react-native-paper": "^4.0.1",
"react-native-reanimated": "^1.9.0",
"react-native-safe-area-context": "^3.0.2",
"react-native-screens": "^2.9.0",
"react-native-tts": "^3.2.0",
"react-native-vector-icons": "^7.1.0",
"react-native-web": "~0.11.7",
"react-navigation": "^4.4.0",
"react-navigation-stack": "^2.8.2",
"yarn": "^1.22.10"
},
"devDependencies": {
"#babel/core": "^7.8.6",
"#types/react": "~16.9.41",
"#types/react-native": "~0.62.13",
"typescript": "~3.9.5"
},
"private": true
}
This is Package.json of my project in react native. How to install cocoa pods in this project I read somewhere that when using expo dependencies in the project you can't install cocoapods in the project so how to install cocoa pods when using expo dependencies
You just can't install cocoa pods when using expo, that simple. If you need some library from react native community that needs to install cocoa pods, you just can't use it unless expo made its own. You can check if that library is available for expo here: https://docs.expo.io/versions/latest/
Almost everything from react native community has its own expo version if needed.
To install, use $ expo install <module-name>.
You should use expo bare workflow if you want to add react native librairies which are not included in expo client already.
With Expo bare workflow you can still use expo modules like expo-ad-mobs and even expo client if you have some fail over strategy for your newly added librairies.
https://docs.expo.io/bare/exploring-bare-workflow/
But you will have to build the app yourself, while expo managed workflow lets you use expo cli & infrastructure to build your ipa/apk.
If you just want to build the app and not add any other library, just use expo cli commands like expo build:ios

Webpack Compile: Cannot find module '#babel/preset-env' when deploy production

i use capistrano to deploy my rails project( Rails 6.0.0, Ruby 2.6.0)
i get bellow log when start `bundle exec cap production deploy
ERROR in ./app/javascript/packs/application.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module '#babel/preset-env'
and
ERROR in ./app/javascript/packs/server_rendering.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module '#babel/preset-env'
But when i test in local RAILS_ENV=production bundle exec rails assets:precompile . It built successful
my package.json
{
"name": "my_app_name",
"private": true,
"dependencies": {
"#babel/preset-react": "^7.0.0",
"#rails/actiontext": "^6.0.0",
"#rails/webpacker": "^4.0.2",
"axios": "^0.19.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"core-js": "2",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react_ujs": "^2.6.0",
"trix": "^1.0.0",
"webpack-dev-server": "^3.3.1"
},
"devDependencies": {
"#babel/preset-env": "^7.7.6",
"babel-preset-env": "^1.7.0",
"webpack-dev-server": "^3.3.1"
}
}
my app/javascript/packs/application.js
// Support component names relative to this directory:
var componentRequireContext = require.context("components", true);
var ReactRailsUJS = require("react_ujs");
ReactRailsUJS.useContext(componentRequireContext);
my app/javascript/packs/server_rendering.js
// By default, this pack is loaded for server-side rendering.
// It must expose react_ujs as `ReactRailsUJS` and prepare a require context.
var componentRequireContext = require.context("components", true);
var ReactRailsUJS = require("react_ujs");
ReactRailsUJS.useContext(componentRequireContext);
any solution? Thank You
Anything you want available when compiling in production mode needs to be in dependencies. Move #babel/preset-env out of devDependencies into dependencies in package.json. You can also delete babel-preset-env since that is redundant.

Rails/Webpacker is not working

I have a Rails/React project. It's using Rails/webpack 3.3.0.
To precompile react code, I executed:
rails assets:precompile RAILS_ENV=development
But I am getting this error:
[Webpacker] Compilation failed:
(node:47256) DeprecationWarning: Tapable.apply is deprecated.
Call apply on the plugin directly instead (node:47256)
DeprecationWarning:
Tapable.plugin is deprecated. Use new API on .hooks instead
TypeError: dep.getResourceIdentifier is not a function
Is this something you faced before? Would you like to help me to fix thsi problem?
Here is my package.json
{
"dependencies": {
"#rails/webpacker": "3.3.0",
"babel-core": "6",
"babel-loader": "^7.1.4",
"babel-preset-react": "^6.24.1",
"caniuse-lite": "^1.0.3000697",
"classnames": "^2.2.5",
"coffee-loader": "^0.9.0",
"coffeescript": "^2.2.2",
"debounce": "^1.1.0",
"es6-shim": "^0.35.3",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"mobile-detect": "^1.4.1",
"prop-types": "^15.6.1",
"react": "16.0.0",
"react-addons-css-transition-group": "^16.0.0-alpha.3",
"react-addons-update": "^15.6.2",
"react-bootstrap": "^0.32.1",
"react-dom": "^16.2.0",
"react-dom-factories": "^1.0.2",
"react_ujs": "^2.4.4",
"uglifyjs-webpack-plugin": "^1.2.5",
"webpack": "4.0.0"
},
"devDependencies": {
"webpack-cli": "^2.0.15",
"webpack-dev-server": "^3.1.0"
},
"license": "UNLICENSED",
"private": true
}
The version of Webpacker you are using isn't compatible with Webpack 4.
However, it looks like support is close, Webpack 4.x support has been merged:
https://github.com/rails/webpacker/pull/1316
And there's a Webpacker 4.x preview release:
https://rubygems.org/gems/webpacker
So I believe you want to use Webpack 3.x for the time being, or go bleeding edge and try the prerelease.
With that said, I'm going to give the prerelease a go, I've been waiting for Webpack 4.x support!

Resources