WSL unable to run express server while developing a mern stack app - reactjs

I am a software engineering student on WSL. To start my development I typically run two different commands. npm start for the dev server and for the express server I run nodemon server. However, I am getting so many different errors that I don't know exactly where to start. The server worked until recently when I incorporated passport, jwt, passport_jwt, for user authentication. I was following along in class and even tried git cloning down the teachers repository to see if the error was on my side(like my code). However, not even that seemed to solve my issue. I got it to run exactly once. In that instance, the the options in my package.json read as follows:
"options": {
"allowedHosts": ["localhost", ".localhost"],
"proxy": "http://localhost:3003"
}
At this time, my server.js read as having the port as 3002, with the react server starting on port 3000. To match my teachers example, I killed the ports, set the port number in my server.js to match what was in the package.json. Since then I have tried reverting that back to what I had it. But I just get errors. Here are the errors I am getting:
node:internal/fs/utils:346
throw err;
^
Error: ENOENT: no such file or directory, stat '/mnt/c/Users/Patrick/Va Design Group Dropbox/Pat Mangan/PC (2)/Desktop/sei_work/mern-stack/mern-demo/build/favicon.ico'
at Object.statSync (node:fs:1601:3)
at resolveSync (/mnt/c/Users/Patrick/Va Design Group Dropbox/Pat Mangan/PC (2)/Desktop/sei_work/mern-stack/mern-demo/node_modules/serve-favicon/index.js:187:17)
at favicon (/mnt/c/Users/Patrick/Va Design Group Dropbox/Pat Mangan/PC (2)/Desktop/sei_work/mern-stack/mern-demo/node_modules/serve-favicon/index.js:61:12)
at Object.<anonymous> (/mnt/c/Users/Patrick/Va Design Group Dropbox/Pat Mangan/PC (2)/Desktop/sei_work/mern-stack/mern-demo/server.js:17:9)
at Module._compile (node:internal/modules/cjs/loader:1246:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1300:10) at Module.load (node:internal/modules/cjs/loader:1103:32)
at Module._load (node:internal/modules/cjs/loader:942:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47 {
errno: -2,
syscall: 'stat',
code: 'ENOENT',
path: '/mnt/c/Users/Patrick/Va Design Group Dropbox/Pat Mangan/PC (2)/Desktop/sei_work/mern-stack/mern-demo/build/favicon.ico'
}
[nodemon] starting `node server.js`
node:internal/modules/cjs/loader:1332
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: /mnt/c/Users/Patrick/Va Design Group Dropbox/Pat Mangan/PC (2)/Desktop/sei_work/mern-stack/mern-infrastructure/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
at Module._extensions..node (node:internal/modules/cjs/loader:1332:18)
at Module.load (node:internal/modules/cjs/loader:1103:32)
at Module._load (node:internal/modules/cjs/loader:942:12)
at Module.require (node:internal/modules/cjs/loader:1127:19)
at require (node:internal/modules/helpers:112:18)
at Object.<anonymous> (/mnt/c/Users/Patrick/Va Design Group Dropbox/Pat Mangan/PC (2)/Desktop/sei_work/mern-stack/mern-infrastructure/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (node:internal/modules/cjs/loader:1246:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1300:10)
at Module.load (node:internal/modules/cjs/loader:1103:32)
at Module._load (node:internal/modules/cjs/loader:942:12) {
code: 'ERR_DLOPEN_FAILED'
}
Any help would be appreciated.
I switched ports around, I uninstalled things, I deleted my node modules. I made an exact copy from scratch to see if something along the way broke. I have tried everything.

Related

i accidently deleted some my node modules file while first time creating react app by terminal

Node.js v18.12.1
PS D:\CS\0. Code\github> npx create-react-app .
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module '../remove'
Require stack:
- C:\Users\HP\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\fs-extra\lib\empty\index.js
- C:\Users\HP\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\fs-extra\lib\index.js
- C:\Users\HP\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\createReactApp.js
- C:\Users\HP\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\Users\HP\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\fs-extra\lib\empty\index.js:7:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\HP\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\fs-extra\\lib\\empty\\index.js',
'C:\\Users\\HP\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\fs-extra\\lib\\index.js',
'C:\\Users\\HP\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\create-react-app\\createReactApp.js',
'C:\\Users\\HP\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\create-react-app\\index.js'
]
}
while i was first time creating react app, my internet connection broke at middle. so i deleted some install file,
when i was creating it second time, terminal give me this error.
i tryed npm install to reinstal module but its not gime me proper solution
currently
i have this four file in my working folder
node_modules
index.html
package-lock.json
pacakage.json
plz help me to resolve this issue
try this commands in your terminal
rm -rf node_modules package-lock.json
npm install --force
Some different way I mention here:
Way 1. if you are creating a new project then delete the older project, and also delete it from recycle bin. Now create a new application again.
Way 2. Again the same problem occurs then follow 1st way and then clear your temp file and then try to create a new application.
temp clear steps for windows OS.
press ctr + R for open cmd.
1 -> type "temp" and delete all files,
2 -> type "%temp%" and delete all files,
3 -> type "prefetch" and delete all files
Way 3. Reinstall npm.

cant require canvacord in discord.js

when i try to use const Canvas = require("canvacord") it gives this error
Error: libuuid.so.1: cannot open shared object file: No such file or directory
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
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)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/runner/bot/node_modules/canvas/lib/bindings.js:3:18)
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)
Hint: hit control+c anytime to enter REPL.
is there a way to fix this?
Due to a lack of context and instructions I was unable to reproduce your issue. Although, assuming that you are using Repl.it, there is a comment about a similar issue available on Github:
If you are facing this error at replit
Follow this steps to fix it:
Click on three dots and then click on show hidden files
Go to file name 'replit.nix'
now under deps add: pkgs.libuuid
now after deps go to a fresh line (make sure there are no syntax conflicts), and paste this:
env = { LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [pkgs.libuuid]; };
Tada 🎉 your error is fixed, enjoy and thank me later :)
If this doesn't work, make sure you installed libuuid which is a dependency of node-canvas which itself is a dependency fo canvacord. Should be already installed on most Linux machines but maybe it's not... Run: apt-get install libuuid1

Yarn start not working for react js after tried setting react native environment mac m1

ajayror#Ajays-MacBook-Air phgh % yarn start
yarn run v1.22.11
warning ../../package.json: No license field
$ react-scripts start
node:internal/modules/cjs/loader:488
throw e;
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in /Users/ajayror/Desktop/phgh/node_modules/postcss-safe-parser/node_modules/postcss/package.json
at new NodeError (node:internal/errors:371:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:416:9)
at packageExportsResolve (node:internal/modules/esm/resolve:669:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/ajayror/Desktop/phgh/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Node.js v17.0.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
It seems like we all are facing the same issue, it's taken me so long to solve this problem. Simply follow this, uninstall the current version of node (v17.0.1) and install LTS(v16.13.1). I hope it will work no matter what.
Thanks for your douth.

angular-cli produces syntax error when ran

I am trying to use the angular-cli project however I get this error when I run
$ ng new scotchy-scotch
C:\Users\....\AppData\Roaming\nvm\v0.12.10\node_modules\angular-cli\bin\ng:7
const resolve = require('resolve');
^^^^^
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
From the angular-cli github page:
Prerequisites:
Both the CLI and generated project have dependencies
that require Node 4 or higher, together with NPM 3 or higher.
The const are part of ES6(ECMAscript 2015) which is not enabled by default in nodejs v0.12(which one you use). Related stackoverflow article

Loopback: Cannot find module 'negotiator'

I'm trying to use Loopback to create an api for my existing database. When I try to 'discover' the model, I get this error:
Message: Cannot find module 'negotiator'
Request: /workspace/api/DataSourceDefinitions/server.tweetvtds/testConnection
Staus: 500
Error: Cannot find module 'negotiator'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (~/lb/node_modules/loopback/node_modules/express/node_modules/accepts/index.js:1:80)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
I read elsewhere that I should try:
# uninstall the existing version
npm uninstall -g generator-loopback
# install it again
npm install -g generator-loopback
But that didn't help. What does this error mean and how do I fix it?
It turns out that the initial build of the project didn't fully complete.
During the initial build, Loopback printed the following:
I'm all done. Running npm install for you to install the required
dependencies. If this fails, try running the command yourself.
create .editorconfig
create .jshintignore
create .jshintrc
create README.md
create server/boot/authentication.js
create server/boot/explorer.js
create server/boot/rest-api.js
create server/boot/root.js
create server/middleware.json
create server/server.js
create .gitignore
create client/README.md
It failed to complete this step; however, running 'npm install' myself didn't fix the problem for some reason. So, I just built a new loopback project and everything is working fine now.

Resources