gulp serve showing error when trying to create sharepoint clent development - sharepoint

gulp serve showing error like below
fs.js:27
const { Math, Object } = primordials;
^
Reference: primordials is not defined
at fs.js:27:26
at req_ (E:\Sharepoint\react-app\node_modules\natives\index.js:143:24)
at Object.req [as require] (E:\Sharepoint\react-app\node_modules\natives\index.js:55:10)
at Object. (E:\Sharepoint\react-app\node_modules\vinyl-fs\node_modules\graceful-fs\fs.js:1:37)

Related

I keep running into the same error after trying to run Node User routes

I keep getting an error in my express-promise-router
var wrapHandler = function (handler) {if ("function" !== typeof handler) { var type = Object.prototype.toString.call(handler); var msg = "Expected a callback function but got a " + type; throw new Error(msg); } var handleReturn = function (args) { // Find the next function from the arguments var next = args.slice(-1)[0];
`Error is as follows:-
node_modules/express-promise-router/lib/express-promise-router.js:10
throw new Error(msg);
^`
Error: Expected a callback function but got a [object Undefined]
at /Users/alfredbanda/jobplus-backend/node_modules/express-promise-router/lib/express-promise-router.js:104:16 at Array.map (<anonymous>) at instanceToWrap.<computed> [as post] (/Users/alfredbanda/jobplus-backend/node_modules/express-promise-router/lib/express-promise-router.js:103:32) at Object.<anonymous> (/Users/alfredbanda/jobplus-backend/src/routes/auth.routes.js:4:8) at Module._compile (node:internal/modules/cjs/loader:1239:14) at Module._extensions..js (node:internal/modules/cjs/loader:1293:10) at Module.load (node:internal/modules/cjs/loader:1096:32) at Module._load (node:internal/modules/cjs/loader:935:12) at Module.require (node:internal/modules/cjs/loader:1120:19)
Node.js v19.4.0
[nodemon] app crashed - waiting for file changes before starting...
I know there is a problem with the callback function being passed to the "express-promise-router" module. Specifically, the error message says that it expected a callback function, but instead got an object of type "Undefined". I checked the function call and ensured that the correct callback function is being passed as an argument but to no avail.

Why am I getting module not found when I have double and triple checked that it is there?

So I'm trying to search google programmatically, and to do so i'm using the node module google-search-results-nodejs, but despite anything I do I keep getting the error not found. I'm working on gitpod online workspace. I wasn't sure if perhaps this had something to do with it but for the life of me I just can't figure it out, and I've looked elsewhere and can't find anything. I tried to check if perhaps my files were in the wrong location, tried uninstalling all node-modules folder and reinstalling it.
Any ideas
const SearchAPI = require('google-search-results-nodejs');
const search = new SearchAPI.GoogleSearchResults(
"663185d5-API-KEY-76787e11787a9"
);
const params = {
engine: 'google_reverse_image',
image_url: 'https://i.imgur.com/E4cOSLw.jpg',
};
const cb = function (data) {
console.log(data['inline-images']);
};
// here
search.json(params, cb);
Here's the error response:
gitpod /workspace/Copyright-Content-Removal/node_modules $ node app.js
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module '/workspace/Copyright-Content-Removal/node_modules/app.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
EDIT: Just retested it and am getting this https://ibb.co/YPBX5Y1 error message.... Also I attached a video link below
Your app.js is inside node_modules directory -
/workspace/Copyright-Content-Removal/node_modules/app.js
But actually your app.js should be outside the node_modules directory like this -
/workspace/Copyright-Content-Removal/app.js

Why does this NPM package say it is not a constructor?

I am working on a Sails.js project that requires me to use this NPM package. I created a new Sails.js service to invoke this package after npm install-ing it like this:
// Require and initialize the rules engine
var jsonRulesEngine = require('json-rules-engine'),
rulesEngine = new jsonRulesEngine();
When I run this script, I get the following error:
/Users/Nag/Code/learn-nodejs/server/node_modules/bluebird/js/release/async.js:61
fn = function () { throw arg; };
^
TypeError: jsonRulesEngine is not a constructor
at Object.verify (/Users/Nag/Code/learn-nodejs/server/api/services/RulesService.js:21:27)
at Object.wrapper [as verify] (/Users/Nag/Code/learn-nodejs/server/node_modules/#sailshq/lodash/lib/index.js:3250:19)
at /Users/Nag/Code/learn-nodejs/server/api/controllers/UtilsController.js:113:43
at /Users/Nag/Code/learn-nodejs/server/api/services/RedisService.js:55:13
at tryCatcher (/Users/Nag/Code/learn-nodejs/server/node_modules/bluebird/js/release/util.js:16:23)
at Promise.successAdapter [as _fulfillmentHandler0] (/Users/Nag/Code/learn-nodejs/server/node_modules/bluebird/js/release/nodeify.js:23:30)
at Promise._settlePromise (/Users/Nag/Code/learn-nodejs/server/node_modules/bluebird/js/release/promise.js:566:21)
at Promise._settlePromise0 (/Users/Nag/Code/learn-nodejs/server/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/Nag/Code/learn-nodejs/server/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/Users/Nag/Code/learn-nodejs/server/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Users/Nag/Code/learn-nodejs/server/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/Nag/Code/learn-nodejs/server/node_modules/bluebird/js/release/async.js:17:14)
at Immediate.<anonymous> (/Users/Nag/Code/learn-nodejs/server/node_modules/async-listener/glue.js:188:31)
at runCallback (timers.js:666:20)
at tryOnImmediate (timers.js:639:5)
at processImmediate [as _immediateCallback] (timers.js:611:5)
[nodemon] app crashed - waiting for file changes before starting...
Any clue why I might get that error? In the examples section of the package, the owner of the package imports the package using ES6 format whereas I am requiring it. Does that make a difference?
When you require an NPM package, depending on your module system1, the default export will not automatically be imported when you do this:
var jsonRulesEngine = require('json-rules-engine');
So when you require like you did, it will return the module object, not necessarily the default export as expected. In the package json-rules-package the Engine is exported by default but your require doesn't require the default. If you log the returned module object it will look like this:
{
Engine: function(...) { ... },
Fact: function(...) { ... },
Operator: function(...) { ... },
Rule: function(...) { ... },
default: function(...) { ... }
}
The engine is under the property default and Engine. You could do:
var jsonRulesEngine = require('json-rules-engine').default();
Or:
var jsonRulesEngine = require('json-rules-engine').Engine;
The first will explicitly import the default export. Then you can create an instance of the class like so:
var rulesEngine = new jsonRulesEngine();
1 Yes, using ES2015 import will affect the outcome. If you were to use import syntax from ES2015, this problem would not be encountered. To know why see this answer. In short, Babel transpiles ES2015 code so that default is explicitly accessed when requiring thus importing the default export.

Error: Module version mismatch. when trying to launch in electron shell

When I try to launch my app in electron shell I get the below error:
I'm using node v0.12.3
I have installed electron-prebuilt
Uncaught Exception:
Error: Module version mismatch. Expected 43, got 14.
at Error (native)
at Object.module.(anonymous function) (ATOM_SHELL_ASAR.js:118:20)
at Object.module.(anonymous function) [as .node] (ATOM_SHELL_ASAR.js:118:20)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:298:12)
at Module.require (module.js:353:17)
at require (module.js:372:17)
at bindings (/src/git/superqa/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44)
at Object.<anonymous> (/src/git/superqa/node_modules/bcrypt/bcrypt.js:3:35)
at Module._compile (module.js:418:26)
// my main.js file looks like this superqa/main.js
var app = require("./app/app.js");
var App = require("./src/app.js");
new App(app);
//my src/app.js looks like this superqa/src/app.js
var path = require("path");
var BrowserWindow = require('browser-window');
module.exports = App;
function App(app) {
var self = this;
this._app = app;
this._assetDir = path.resolve(__dirname, "..", "dist");
this.mainWindow = null;
app.on('ready', function() {
self.mainWindow = new BrowserWindow({
width: 1024,
height: 768
});
self.mainWindow.loadUrl("http://localhost:3000/login");
});
}
The problem is that the pre-built binaries were built with io.js 1.x, which uses a different (higher) ABI version than node.js. So if you want to use the pre-built version, you have to use io.js 1.x. Otherwise you will have to build electron yourself if you want to keep using node 0.12.x.

Browserify/Jadeify: require maps no longer supported

I am trying to use browserify/jadeify on my ExpressJS project:
server.coffee
browserify = require "browserify"
jadeify = require "jadeify"
bundle = browserify()
.use(jadeify(__dirname + "/client/jade/templates"))
.addEntry(__dirname + "/public/js/app/main.js")
app.use bundle
main.coffee (client side)
$ = require "jquery"
jadeify = require "jadeify"
html = jadeify "test.jade",
title: "Hello World"
console.log html
What I got is:
Error: require maps no longer supported
at Function.Wrap.require (/labs/Projects/Nodebook/node_modules/browserify/lib/wrap.js:410:15)
at Function.module.exports.Object.keys.forEach.self.(anonymous function) [as require] (/labs/Projects/Nodebook/node_modules/browserify/index.js:158:28)
at module.exports (/labs/Projects/Nodebook/node_modules/jadeify/index.js:53:16)
at Function.Wrap.use (/labs/Projects/Nodebook/node_modules/browserify/lib/wrap.js:105:5)
at Function.module.exports.Object.keys.forEach.self.(anonymous function) [as use] (/labs/Projects/Nodebook/node_modules/browserify/index.js:158:28)
at Object.<anonymous> (/labs/Projects/Nodebook/server.coffee:55:25)
at Object.<anonymous> (/labs/Projects/Nodebook/server.coffee:63:4)
at Module._compile (module.js:449:26)
at Object.exports.run (/usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:83:25)
at compileScript (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:177:29)
Seems like the server does not want to start. How do I get this to work? I think the code is mostly the same as in the documentation. Whats wrong and how do I fix this?

Resources