passport component registration field (MODULE_NOT_FOUND) after mounting loopback 3 inside loopback4 - loopback

I am trying to upgrade from loopback 3 to loopback 4 using "mounting strategy" according to the documentation.
while trying to run the app using npm start, i am getting the following error:
node -r source-map-support/register .
Cannot start the application. { Error: Cannot find module
'../../node_modules/loopback-component-passport/lib/models/utils.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (C:\Data\myComp\app\myapp_docker\services\myapp_auth\lb3app\server\utils\providerUtils.js:2:15)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (C:\Data\myComp\app\myapp_docker\services\fauth\lb3app\server\server.js:6:25)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32) code: 'MODULE_NOT_FOUND' } npm ERR! code ELIFECYCLE npm ERR! errno 1
I checked and i have the module in the node_modules directory and the utils.js file.

I had to search in all my app files for the string "node_modules" and I found that the relative path for that directory was incorrect. had to add one more "../" before the node_modules.

Related

nx.js using capacitor Cannot find module 'nx/src/utils/app-root'

In my NX project, I have a capacitor Angular 14 application, when using cap:sync, I get the following error which stomps me.
> nx run caregiver:sync:ios --verbose=true
> NX Cannot find module 'nx/src/utils/app-root'
Require stack:
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/#nxtend/capacitor/node_modules/#nrwl/devkit/index.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/#nxtend/capacitor/src/executors/cap/executor.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/src/config/workspaces.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/src/command-line/run.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/bin/run-executor.js
Error: Cannot find module 'nx/src/utils/app-root'
Require stack:
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/#nxtend/capacitor/node_modules/#nrwl/devkit/index.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/#nxtend/capacitor/src/executors/cap/executor.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/src/config/workspaces.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/src/command-line/run.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/bin/run-executor.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/#nxtend/capacitor/node_modules/#nrwl/devkit/index.js:182:18)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
My nx report is the following: I use node 16, nx 14 and capacitor 13. I have research on the subject but can't seem to find the right answer.

!MODULE NOT FOUND" When running node index.js w/npm

I've borrowed a code off Github, but when I try to run the code, this error comes up:
Error: Cannot find module 'C:\Users\Ihate\Desktop\hashlips_art_engine/node_modules/sha1'
- C:\Users\Ihate\Desktop\hashlips_art_engine\index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\Ihate\Desktop\hashlips_art_engine\src\main.js:4:14)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Ihate\\Desktop\\hashlips_art_engine\\src\\main.js',
'C:\\Users\\Ihate\\Desktop\\hashlips_art_engine\\index.js'
]
I don't quite understand this error even after an hour or so of research. I can confirm that those two files do exist in the correct location.
Please ask questions if this isn't clear or if you need information, I'll try to get back to you as soon as I can.

How can I solve this yeoman generator code error

I tried installing code-generator to create my own syntax highlighting in vscode. However, when I tried running code with yo code, this happened :
yo code
/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/resolver.js:70
filePatterns: lookups.flatMap(prefix => [`${prefix}/*/index.ts`, `${prefix}/*/index.js`, `${prefix}/*/index.cjs`, `${prefix}/*/index.mjs`]),
^
TypeError: lookups.flatMap is not a function
at Environment.resolver.lookup (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/resolver.js:70:27)
at init (/usr/local/lib/node_modules/yo/lib/cli.js:130:7)
at pre (/usr/local/lib/node_modules/yo/lib/cli.js:89:3)
at Object.<anonymous> (/usr/local/lib/node_modules/yo/lib/cli.js:219:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
Do you have any idea how I can fix it ?
Try updating NPM. That fixed it for me anyway.

TypeError: smarthome is not a function

We are trying to implement Report State API at github openhab project.
We are using “actions-on-google” version “2.6.0”.
We have added below lines to openhab.js file
const {smarthome} = require('actions-on-google');
const app = smarthome({
});
Please find the below console output:
smartfueb_march_gmail_com#instance-1-ubuntu16:/home/smartfueb_march/openhab-google-assistant/functions$ gcloud beta functions deploy openhabGoogleAssistant --stage-bucket smart_test1 --trigger-http
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Code in file index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: TypeError: smarthome is not a function
at Object. (/user_code/openhab.js:23:13)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object. (/user_code/index.js:18:17)
at Module._compile (module.js:577:32)
We could resolve the issue of smarthome is not function by using below commands and changing the package.json file to 2.6.0.
$ sudo npm install -g actions-on-google#latest

visual studio code SyntaxError: Unexpected identifier with node . discord bot coding

I am new to coding when I try to run this command
var commando = require("discord.js-commando");
var yourbot = new commando.client();
yourbot.login('MzI1MDI2MzQ4NzEwMjMyMDY2.DCSP8Q.Xyn-k0_DfnV4x3WsKtfDPBM0KfU');
and then I type node . I get this
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:78:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/myusername/Desktop/Cyborg Pasta/node_modules/discord.js-commando/src/index.js:4:10)
at Module._compile (module.js:571:32)
Ians-MBP:Cyborg Pasta iankalman$ node .
/Users/iankalman/Desktop/Cyborg Pasta/node_modules/discord.js-commando/src/client.js:144
async setProvider(provider) {
^^^^^^^^^^^`
delete your node_modules folder and try reinstalling your modules with npm. Also, never post your bot token online you need to revoke that token.