Node/Gulp failing (can't load gulp-sass) outside Visual Studio - node.js

We are setting up Gulp with our VS project. When running the tasks from the VS Task Runner, they work flawlessly, but from the command line, it's failing.
Package.json:
{
"name": "OurProject",
"description": "OurProject",
"repository": {
"type": "git",
"url": "https://github.com/something.git"
},
"private": true,
"devDependencies": {
"gulp": "^3.9.0",
"gulp-cached": "^1.1.0",
"gulp-coffee": "^2.3.1",
"gulp-notify": "^2.2.0",
"gulp-sass": "^2.0.4",
"gulp-sourcemaps": "^1.5.2"
}
}
Gulpfile.js (simplified):
var
gulp = require('gulp'),
sass = require('gulp-sass');
gulp.task('scss-compile', function () {
return gulp
.src("./Web/css/**/*.scss")
.pipe(sass())
.pipe(gulp.dest("./Web/css"));
});
Visual Studio claims to be using this command line:
cmd.exe /c gulp -b "C:\AbsoluteProjectPath" --color --gulpfile "C:\AbsoluteProjectPath\Gulpfile.js" scss-compile
Which doesn't work if I try it, because it can't find Gulp. So, I changed the current directory to C:\AbsoluteProjectPath and ran:
cmd.exe /c node_modules\.bin\gulp -b "C:\AbsoluteProjectPath" --color --gulpfile "C:\AbsoluteProjectPath\Gulpfile.js" scss-compile
And I got the following:
C:\AbsoluteProjectPath\node_modules\gulp-sass\node_modules\node-sass\lib\extensions.js:148
throw new Error(['`libsass` bindings not found in ', binaryPath, '. Try re
^
Error: `libsass` bindings not found in C:\AbsoluteProjectPath\node_modules\gulp-sass\node_modules\node-sass\vendor\win32-ia32-14\binding.node. Try reinstalling `node-sass`?
at Object.sass.getBinaryPath (C:\AbsoluteProjectPath\node_modules\gulp-sass\node_modules\node-sass\lib\extensions.js:148:11)
at Object.<anonymous> (C:\AbsoluteProjectPaths\node_modules\gulp-sass\node_modules\node-sass\lib\index.js:16:36)
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)
at require (module.js:384:17)
at Object.<anonymous> (C:\AbsoluteProjectPath\node_modules\gulp-sass\index.js:163:21)
at Module._compile (module.js:460:26)
Now, that win32-ia32-14 folder doesn't exist. There is a win32-ia32-11 instead.
What might be happening here?

This turned out to be Visual Studio using a different version of node.js that resolves to a different list of packages.

Related

use the Dbus package in an electron app (Build process)

i have this problem when i require DBus from the dbus package
const { app, BrowserWindow } = require("electron");
const DBus = require('dbus');
app.whenReady().then(() => {
var win = new BrowserWindow({ width: 600, height: 500 });
win.loadFile('index.html');
win.webContents.openDevTools();
});
so when i execute this code i get this error :
> electron script.js
App threw an error during load
Error: Module did not self-register: '/home/bislem/projects/test/electron/node_modules/dbus/build/Release/dbus.node'.
at process.func [as dlopen] (electron/js2c/asar.js:140:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1196:18)
at Object.func [as .node] (electron/js2c/asar.js:140:31)
at Module.load (internal/modules/cjs/loader.js:981:32)
at Module._load (internal/modules/cjs/loader.js:881:14)
at Function.Module._load (electron/js2c/asar.js:769:28)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/home/bislem/projects/test/electron/node_modules/dbus/lib/dbus.js:3:13)
at Module._compile (internal/modules/cjs/loader.js:1145:30)
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Module did not self-register: '/home/bislem/projects/test/electron/node_modules/dbus/build/Release/dbus.node'.
at process.func [as dlopen] (electron/js2c/asar.js:140:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1196:18)
at Object.func [as .node] (electron/js2c/asar.js:140:31)
at Module.load (internal/modules/cjs/loader.js:981:32)
at Module._load (internal/modules/cjs/loader.js:881:14)
at Function.Module._load (electron/js2c/asar.js:769:28)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/home/bislem/projects/test/electron/node_modules/dbus/lib/dbus.js:3:13)
at Module._compile (internal/modules/cjs/loader.js:1145:30)
I searched for this error and tried some solutions but none of them worked (npm rebuild,npm update,delete the node_modules folder then npm install,use a diffrent version of node using the nvm command), but when runing each package by his own, (run electron using the start script electron ., and run dbus with node script.js) they works correctly.
and there was this when installing the dbus package :
console when installing dbus, console when installing dbus part 2
my package.json file :
{
"name": "electrontest",
"version": "1.0.0",
"description": "",
"main": "script.js",
"scripts": {
"start": "electron script.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bootstrap": "^4.5.3",
"dbus": "^1.0.7",
"electron": "^10.1.5"
}
}
so my question is what is the correct way to Build/Run such code ? || how to use these two packages side by side ?
You need to run
npm install --save-dev electron-rebuild && npx electron-rebuild
More on using native node modules in electron here

Error: Cannot find module 'selenium-selenium'

Versions are:
nvm --version 0.35.3
npm -v: 6.14.8
node -v: v14.10.0
important package.json parts:
{
"main": "index.js",
"scripts": {
"start": "./node_modules/mocha/bin/mocha index.js",
"install": "bash install.sh",
"clear": "rm -R -f node_modules && rm package-lock.json"
},
"dependencies": {
"chromedriver": "^84.0.1",
"dotenv": "^8.2.0",
"mocha": "^8.1.2",
"selenium-webdriver": "^4.0.0-alpha.7"
}
}
index.js:
require('dotenv').config()
const password = process.env.PASSWORD;
const selenium = require('selenium-selenium');
const chrome = require('selenium-selenium/chrome');
const chromedriver = require('chromedriver');
describe('Init driver and login', () => {
//... Should run through as an empty test but does not
});
and the error I'm getting when I'm running mocha index.js or npm run start:
Error: Cannot find module 'selenium-selenium'
Require stack:
- /home/mts/Desktop/projects/selenium/index.js
- /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/esm-utils.js
- /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/mocha.js
- /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/cli/one-and-dones.js
- /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/cli/options.js
- /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/bin/mocha
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:893:15)
at Function.Module._load (internal/modules/cjs/loader.js:743:27)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/mts/Desktop/projects/selenium-moco/index.js:11:18)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.exports.requireOrImport (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/esm-utils.js:20:12)
at Object.exports.loadFilesAsync (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/esm-utils.js:33:34)
at Mocha.loadFilesAsync (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/mocha.js:427:19)
at singleRun (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/cli/run-helpers.js:156:15)
at exports.runMocha (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/cli/run-helpers.js:225:10)
at Object.exports.handler (/home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/lib/cli/run.js:366:11)
at /home/mts/.nvm/versions/node/v14.10.0/lib/node_modules/mocha/node_modules/yargs/lib/command.js:241:49
As simple as possible, but the module is not found - why? Should I try the lowest versions possible? I wanted to avoid the compatibility hell so I used only the newest versions available.
I think you use incorrect package name in your code - selenium-selenium. This package doesn't available on npmjs.org.
Try change this lines in our code:
const selenium = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

Can't deploy functions with Crashlytics triggers

I write many functions that trigger by Firebase features and I can deploy them but only functions that trigger by Crashlytics I can't deploy.
exports.sendOnVelocityAlert = functions.crashlytics.issue().onVelocityAlert(event => {
const data = event.data;
const issueId = data.issueId;
const issueTitle = data.issueTitle;
const appName = data.appInfo.appName;
const appPlatform = data.appInfo.appPlatform;
const latestAppVersion = data.appInfo.latestAppVersion;
const crashPercentage = data.velocityAlert.crashPercentage;
const slackMessage = `<!here|here> There is an issue ${issueTitle} (${issueId}) ` + `in ${appName}, version ${latestAppVersion} on ${appPlatform} that is causing ` + `${parseFloat(crashPercentage).toFixed(2)}% of all sessions to crash.`;
return notifySlack(slackMessage)/then(() => {
console.log(`Posted velocity alert ${issueId} successfully to Slack`);
});
});
I always see this error "Cannot read property 'issue' of undefinded" when I deploy.
i deploying functions
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
Error: Error occurred while parsing your function triggers.
TypeError: Cannot read property 'issue' of undefined
at Object.<anonymous> (/private/var/folders/y8/tbbq9y5j12jc5rlwcmt5smgm0000gn/T/fbfn_10408f4KU3uXJsLQc/index.js:261:53)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:18:11
at Object.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:32:3)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
I use Firebase CLI v3.16.0, node v8.9.3, npm v5.5.1 and version of dependencies in package.json are below.
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"dependencies": {
"#google-cloud/storage": "^1.5.1",
"child-process-promise": "^2.2.1",
"firebase-admin": "^5.6.0",
"firebase-functions": "^0.7.5",
"mkdirp": "^0.5.1",
"mkdirp-promise": "^5.0.1",
"request": "^2.83.0",
"request-promise": "^4.2.2",
"uuid": "^3.1.0"
},
"private": true
}
Any ideas to fix this problem?
The Firebase CLI runs the code you have locally to parse your triggers. Though your package.json has a completely valid dependency, it looks like the version of firebase-functions you have installed is from before firebase.crashlytics was a introduced in October.
Could you try running npm install from your functions directory and see if that fixes the issue?

react-native command gives syntaxerror

Currently using react-native-cli: 1.0.0 and react-native: 0.26.3
Running react-native command in terminal gives this error.
/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229
throw err;
^
SyntaxError: /Users/appleuser/package.json: Error while parsing JSON - Unexpected end of input
at Object.parse (native)
at OptionManager.addConfig (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:225:62)
at OptionManager.findConfigs (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:442:30)
at OptionManager.init (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:484:12)
at compile (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-register/lib/node.js:112:69)
at loader (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-register/lib/node.js:158:14)
at Object.require.extensions.(anonymous function) [as .js] (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-register/lib/node.js:168:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
Anyone got a clue? Couldn't find anything online :(
This is my package.json
{
"name": "asklegit",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"ios": "react-native run-ios",
"android": "react-native run-android"
},
"dependencies": {
"react": "15.0.2",
"react-native": "0.26.3"
}
}
I don't know under which circumstances but it seems sometimes there is an empty package.json created in the users home directory. A completely empty file is by default not correct syntax so calling applications will produce an error.
Solution is to just delete the empty package.json.

Cannot find module 'browser-window' with nightmare and nodejs

I'm having hard time to run nightmare from nodejs. I started with the example provided in the README, tried different version of electron-prebuilt and different tweaks but I'm always getting node that can't find the browser-window module.
Here is my test :
> node --version
v5.3.0
>
> cat .\package.json
{
"name": "webautomation",
"version": "1.0.0",
"private": true,
"description": "testing nightmare.js",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"nightmare": "^2.1.2",
"vo": "^1.0.3"
},
"author": "ECH",
"license": "ISC"
}
>
> npm install
>
> npm ls electron-prebuilt
webautomation#1.0.0 D:\MyEnv\WebAutomation
└─┬ nightmare#2.1.2
└── electron-prebuilt#0.35.4
>
> cat .\main.js
var Nightmare = require('nightmare');
console.log("require done");
dream = Nightmare();
dream.goto('http://yahoo.com');
dream.end();
>
> node main.js
creation done
module.js:338
throw err;
^
Error: Cannot find module 'browser-window'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (D:\MyEnv\WebAutomation\node_modules\nightmare\lib\runner.js:6:21)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
>
Can someone tell me what I'm missing here ?
I got a similar problem with my app and I think its because there was a change in the API or so. Anyway, what I did to fix it was this:
In the main.js file, I replaced the old line
var BrowserWindow = require('browser-window');
with this
var BrowserWindow = require('electron').BrowserWindow;
and then it worked.
You could refer to the thread here: https://github.com/Polymer/polymer-cli/issues/404

Resources