Can't Make Strapi API Requests Receiving error: Module Did not self-register - node.js

I'm unable to make any API using the Strapi api without getting the below error message.
/Users/xxxxxxxxxxxxx/node_modules/snappy/build/Release/binding.node'.
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at bindings (/Users/xxxxxxxxxxxxx/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/Users/xxxxxxxxxxxxx/node_modules/snappy/snappy.js:2:34)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at Object.require (internal/modules/cjs/helpers.js:101:18)
at _optionalRequire (/Users/xxxxxxxxxxxxx/Documents/xxxxxxxxxxx/node_modules/mongodb/node_modules/optional-require/dist/index.js:111:65)
at x (/Users/xxxxxxxxxxxxx/Documents/xxxxxxxxxxx/node_modules/mongodb/node_modules/optional-require/dist/index.js:172:16)
at Object.retrieveSnappy (/Users/xxxxxxxxxxxxx/Documents/xxxxxxxxxxx/node_modules/mongodb/lib/core/connection/utils.js:49:18)
at Object.<anonymous> (/Users/xxxxxxxxxxxxx/Documents/xxxxxxxxxxx/node_modules/mongodb/lib/core/wireprotocol/compression.js:3:47)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
This error shows up even when I simply do the following:
Run npx create-strapi-app#latest my-project --quickstart
Make a Postman request to /api/auth/local/register/
I expect a user to get created and have a token returned. Instead the above error is shown in the console and a 500 internal error is returned in Postman.
System
Node.js version: v14.19
NPM version:6.14.13
Strapi version: 4.0.7
Database: I've tried with Postgres and SQLLite
Operating system: MacOS 11.6
I've read all the StackOverflow posts regarding this and I've deleted and reinstalled the node_modules file numerous times. I've created multiple Strapi Projects and the same thing happens on all of them.
The interesting part is that I setup one instance with a Dockerfile and deployed this instance to ElasticBeanstalk with a database connecting to an RDS instance.
FROM strapi/base
WORKDIR /strapi-app
COPY ./package.json ./
COPY ./yarn.lock ./
RUN yarn install
COPY . .
ENV NODE_ENV development
RUN yarn build
EXPOSE 1337
CMD ["yarn", "start"]
When I try to run the API commands on that instance they work without an issue. I've exhausted all resources I can think of and I'm still unable to resolve this issue.
UPDATE:
I've since removed all other versions from NVM.
nvm list
v14.19.0
system
I also went out to nodejs.org and downloaded the latest package so my system is using v16.13.2.
Once again removed node_modules and reinstalled. Still the same problem.
I have this in my .bash_profile
###NVM CONFIG###
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion" #This loads nvm bash_completion

I came across the same problem, try this
npm install snappy

Related

Node.js v17.5.0 [nodemon] app crashed - waiting for file changes before starting

Creating node.js connection with mongodb.
MongoDb connection in error
Not getting app is running 8000 and shows "nodemon app crashed waiting for file changes before starting "
const mongoose = require('mongoose');
const express = require("express");
const app=express();
mongoose.connect('mongodb://localhost:27017/test', {useNewUrlParser:true});
const port=8000;
app.listen(port,()=>{
console.log(`App is running at ${port}`);
});
Error Caused:
TypeError: Cannot assign to read only property 'map' of object '#'
at Object. (/Users/praneypareek/Desktop/MERN Working Project/projbackend/node_modules/mongoose/lib/cursor/QueryCursor.js:150:27)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/Users/praneypareek/Desktop/MERN Working Project/projbackend/node_modules/mongoose/lib/query.js:12:21)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/Users/praneypareek/Desktop/MERN Working Project/projbackend/node_modules/mongoose/lib/index.js:27:15)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
Node.js v17.5.0
[nodemon] app crashed - waiting for file changes before starting...
The latest release of Node.JS is what is causing this issue. In your package.json, make sure to set your engine to"engines": { "node": ">=0.12 < 17.5.0" } and you should be fine.
Solution which worked well for me:)
Step 01: Open your terminal and copy paste below command.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | zsh
Wait patiently until its done.
Step 02: sudo vim ./zshrc
Step 03: Press I for Insert Mode and copy paste below command. Must be same in three lines.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
then press ESC key :wq (write and quite).
Step 04: brew install nvm
step 05: nvm install node (which will download latest version node)
step 06: nvm ls-remote (which make all the version available)
step 07: nvm install 14 (An Example)
step 08: nvm use 14 (this make it as default version)
source: https://github.com/nvm-sh/nvm

How to solve this 'SyntaxError: Invalid regular expression' in pm2

I install node.js with pm2, all install fine but when i try to do pm2 monit give me this error.
$ pm2 monit
/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fast-printf/dist/src/tokenize.js:4
const TokenRule = /(?:%(?<flag>([+0-]|-\+))?(?<width>\d+)?(?<position>\d+\$)?(?<precision>\.\d+)?(?<conversion>[%BCESb-iosux]))|(\\%)/g;
^
SyntaxError: Invalid regular expression: /(?:%(?<flag>([+0-]|-\+))?(?<width>\d+)?(?<position>\d+\$)?(?<precision>\.\d+)?(?<conversion>[%BCESb-iosux]))|(\\%)/: Invalid group
at Object.<anonymous> (/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fast-printf/dist/src/tokenize.js:4:19)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fast-printf/dist/src/createPrintf.js:5:20)
at Module._compile (module.js:652:30)
I tried servers nodejs version and always give me this error.
If you paste your regular expression into a regex sandbox, like this one:
https://regex101.com/r/GkwWH2/1
You'll see that it doesn't show any syntax errors.
That would make me suspect that you're running a back-level version of Node JS. And in fact, if you look at your stack trace, you see that you are running Node 8.11.3
at Object.<anonymous> (/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fas
That regular expression is using features (such as named capture groups) that did not come into Node.js until Node v10.*.
I suggest you update to the latest LTS version of Node, version 14.*: from your stack trace it would appear that you're using NVM, so it should be a simple matter of
sudo nvm install lts/fermium
should do it.

Getting an error when running "npx wdio config"

I get the following error when I try to set up "Hello World" test suite into my project by running: "npx wdio config". I followed the instructions on the https://webdriver.io/docs/gettingstarted and still not able to get it to work.
Can someone help me with resolving this:
WDIO Configuration Helper
? Where is your automation backend located? (Use arrow keys)
❯ On my local machine
In the cloud using Experitest
In the cloud using Sauce Labs
In the cloud using Browserstack or Testingbot or LambdaTest or a different service
I have my own Selenium cloud (node:2831) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined
at Object.run (/Users/gustavosuarez/web/mo-appium-wdio-jasmine/node_modules/#wdio/cli/build/index.js:67:19)
at Object.<anonymous> (/Users/gustavosuarez/web/mo-appium-wdio-jasmine/node_modules/#wdio/cli/bin/wdio.js:11:21)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
Seems to be a problem with the latest version of the #wdio/cli dependency. I solved the problem by using an older version and it works now ("#wdio/cli": "7.3.1"). Just add that dependency to your package.json and run yarn or npm install again, then npx wdio config and it should work.

internal modules cjs is not working after yarn upgraded to 1.13.0

I have a react app which is based on react boilerplate. I am running the
following command:
cross-env NODE_ENV=development node --experimental-modules ./server/index.mjs
After upgrading yarn to 1.13.0, I am getting the following error:
(node:11137) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/cjs/loader.js:677
module.reflect.onReady((reflect) => {
^
TypeError: Cannot read property 'onReady' of undefined
at Module.load (internal/modules/cjs/loader.js:677:22)
at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
at Function.Module._load (internal/modules/cjs/loader.js:598:3)
at Module.require (internal/modules/cjs/loader.js:705:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (/Users/mdjahidulislam/workspace/ifs/frontend/node_modules/psl/index.js:14:19)
at Module._compile (internal/modules/cjs/loader.js:799:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
at Module.load (internal/modules/cjs/loader.js:666:32)
at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Seems like module.reflect is undefined. In which scenario it can be undefined and how I can solve the problem.
Thanks in advance for any help and suggestions.
Finally solved it. It was all about nodejs version. I had nodejs version 11.* and then I downgraded it on 10.* and it solved the issue.

Ghost blog, Error while running it on local machine

I have installed ghost blog on Openshift and created local copy to make some changes. I added new theme and deployed it back to openshift. Its working fine but I am not able to run this blog on my local machine.
If I run NPM start, I am getting following error:
> openshift-ghost-quickstart# start C:\Users\darklord\OneDrive\Business\mean
> node index
Unhandled rejection Error: Cannot find module 'C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\sqlite3\lib\binding\node-v47-win32-x64\node_sqlite3.node'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\sqlite3\lib\sqlite3.js:4:15)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Client_SQLite3.initDriver (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\knex\lib\dialects\sqlite3\index.js:41:24)
at new Client_SQLite3 (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\knex\lib\dialects\sqlite3\index.js:15:10)
at Knex.initialize (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\knex\knex.js:109:15)
at Knex (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\knex\knex.js:13:26)
at ConfigManager.set (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\core\server\config\index.js:156:24)
at ConfigManager.init (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\core\server\config\index.js:79:10)
at C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\core\server\config\index.js:273:30
at tryCatcher (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\bluebird\js\main\util.js:26:23)
at Promise._settlePromiseFromHandler (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\bluebird\js\main\promise.js:507:31)
at Promise._settlePromiseAt (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\bluebird\js\main\promise.js:581:18)
at Promise._settlePromises (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\bluebird\js\main\promise.js:697:14)
I though that this errpr has something to do with sqlite3 so I have uninstalled and installed it back but still same error.
Can someone let me know what mistake I am going ?
In case other people are running into this issue.
You are probably running a different node.js version on your local machine.
You could check manually in the {gostblog}\node_modules\ghost\node_modules\sqlite3\lib\binding\ folder if you have a different version than the node-v47-win32-x64 he is asking for.
Just reinstall the Ghost dependencies on your local machine to get it running.

Resources