Heroku + Facebook + NodeJS: cannot find module 'OAuth' - facebook

I am new to NodeJS so this is probably an easy fix. However I was not able to find the solution with my current comprehension level.
I cloned the heroku-facebook-nodejs template from Github, and am trying to do some testing in the development environment on my local server. I am using nodejs version 0.6.10
https://github.com/heroku/facebook-template-nodejs
I modified the package.json as the following:
{
"name": "facebook-template-node",
"version": "0.0.1",
"description": "Template app for Heroku / Facebook integration, Node.js language",
"dependencies": {
"ejs": "0.4.3",
"everyauth": "0.2.18",
"express": "2.5.2",
"facebook-client": "1.3.0",
"facebook": "0.0.3",
"node-uuid": "1.2.0",
"socket.io": "0.8.7",
"connect": "1.8.5"
}
}
I removed the following:
require.paths.unshift(__dirname + '/lib');
and replaced
var socket_manager = require('socket_manager').create(io);
with
var socket_manager = require('lib/socket_manager').create(io);
and then ran npm-install -d to install the modules locally.
When I run node web.js, I get the following error:
system-process:hollow-cloud-1974 ericjang2004$ node web.js
The "sys" module is now called "util". It should have a similar interface.
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'oauth'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/Users/Eric/Desktop/hollow-cloud-1974/node_modules/everyauth/lib/modules/oauth2.js:2:13)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
I am not sure how to proceed. Any tips? I read that Heroku uses an older version of Node, if that helps.

Add "oauth": "0.9.5" to your dependencies in package.json, so it looks like:
"dependencies": {
"ejs": "0.4.3",
"oauth": "0.9.5",
"everyauth": "0.2.18",
"express": "2.5.2",
"facebook-client": "1.3.0",
"facebook": "0.0.3",
"node-uuid": "1.2.0",
"socket.io": "0.8.7",
"connect": "1.8.5"
}
and run npm install -d

running npm install whatever --save instead will ensure that the module gets added to the package json.
you would do npm install whatever --save-dev if its a development dependency...

Related

'gatsby-source-graphql' causes load plugins error quoting 'gatsby/graphql'

I have a working Gatsby install that I've been adding to, however, in trying to build in some graphQL build-time data fetching, I've run into an issue that causes error when running npm start (gatsby develop) or gatsby build.
I installed gatsby-source-graphql as described here:
https://www.npmjs.com/package/gatsby-source-graphql
And I included it in my gatsby-config.js like this:
module.exports = {
// Optional
siteMetadata: {
title: `Title from siteMetadata`,
},
plugins: [
{
resolve: `gatsby-plugin-manifest`,
options: {
name: "Project Template",
short_name: "PT",
start_url: "/",
background_color: "#6b37bf",
theme_color: "#6b37bf",
// Enables "Add to Homescreen" prompt and disables browser UI (including back button)
// see https://developers.google.com/web/fundamentals/web-app-manifest/#display
display: "standalone",
icon: "src/images/icon.png", // This path is relative to the root of the site.
// An optional attribute which provides support for CORS check.
// If you do not provide a crossOrigin option, it will skip CORS for manifest.
// Any invalid keyword or empty string defaults to `anonymous`
crossOrigin: `use-credentials`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
// GraphQL APIs for use during build-time.
// https://www.npmjs.com/package/gatsby-source-graphql
//////////////////////////////////////////////////////
{
resolve: "gatsby-source-graphql",
options: {
// Arbitrary name for the remote schema Query type
typeName: "SpaceX",
// Field under which the remote schema will be accessible. You'll use this in your Gatsby query
fieldName: "spaceX",
// Url to query from
url: "https://api.spacex.land/graphql/",
},
},
// {
// resolve: "gatsby-source-graphql",
// options: {
// // Arbitrary name for the remote schema Query type
// typeName: "SWAPI",
// // Field under which the remote schema will be accessible. You'll use this in your Gatsby query
// fieldName: "swapi",
// // Url to query from
// url: "https://swapi-graphql.netlify.app/.netlify/functions/index",
// },
// },
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
`gatsby-plugin-react-helmet`,
`gatsby-theme-material-ui`,
{
resolve: `gatsby-plugin-nprogress`,
options: {
// Setting a color is optional.
color: `tomato`,
// Disable the loading spinner.
showSpinner: false,
},
},
`gatsby-plugin-transition-link`,
`gatsby-plugin-layout`, // Trial and error showed this needs to be last (But that doesn't mean it will always work in the dev environment, try npm run clean or if that fails - test in build)
],
}
But it produces this error:
Error in "/Users//Documents/projects/project/node_modules/gatsby-source-graphql/gatsby-node.js":
Cannot find module 'gatsby/graphql'
Error: Cannot find module 'gatsby/graphql'
- loader.js:636 Function.Module._resolveFilename
internal/modules/cjs/loader.js:636:15
- loader.js:562 Function.Module._load
internal/modules/cjs/loader.js:562:25
- loader.js:692 Module.require
internal/modules/cjs/loader.js:692:17
- v8-compile-cache.js:159 require
[client]/[v8-compile-cache]/v8-compile-cache.js:159:20
- gatsby-node.js:8 Object.<anonymous>
[tbwa-project-template]/[gatsby-source-graphql]/gatsby-node.js:8:5
- v8-compile-cache.js:178 Module._compile
[client]/[v8-compile-cache]/v8-compile-cache.js:178:30
- loader.js:789 Object.Module._extensions..js
internal/modules/cjs/loader.js:789:10
- loader.js:653 Module.load
internal/modules/cjs/loader.js:653:32
- loader.js:593 tryModuleLoad
internal/modules/cjs/loader.js:593:12
- loader.js:585 Function.Module._load
internal/modules/cjs/loader.js:585:3
- loader.js:692 Module.require
internal/modules/cjs/loader.js:692:17
- v8-compile-cache.js:159 require
[client]/[v8-compile-cache]/v8-compile-cache.js:159:20
- resolve-module-exports.ts:197 resolveModuleExports
[client]/[gatsby]/src/bootstrap/resolve-module-exports.ts:197:26
- validate.ts:348 forEach
[client]/[gatsby]/src/bootstrap/load-plugins/validate.ts:348:31
- Array.forEach
- validate.ts:340 collatePluginAPIs
[client]/[gatsby]/src/bootstrap/load-plugins/validate.ts:340:20
not finished load plugins - 0.727s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project-template#1.0.0 start: `gatsby develop`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project-template#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/_logs/2021-02-04T00_31_34_070Z-debug.log
What I've tried:
I've tried two different gatsby-source-graphql definitions in the config (only ever one at a time), but both produce the error. THe second one (commented out above) is taken directly from The github page example and the Gatsby example.
I've tried changing the order of the plugins (i've tried every position) but still get the error.
If I comment any and all gatsby-source-graphql sections in the config, it doesn't produce the error.
If I comment out all plugins except one of the gatsby-source-graphql sections, I still get the exact same error.
I've also tried removing the node_modules folder, running npm run clean, and then npm install again with no change.
I've tried DanceParty's solution described in the link below as well with no change:
https://github.com/gatsbyjs/gatsby/issues/8249
I've tried running npm update and npm install npm#latest -g and saw no change.
My environment report using gatsby info --clipboard is:
System:
OS: macOS 10.15.7
CPU: (4) x64 Intel(R) Core(TM) i5-6287U CPU # 3.10GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.23.1 - /usr/local/bin/node
npm: 6.14.10 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 88.0.4324.96
Firefox: 85.0
Safari: 14.0.2
npmPackages:
gatsby: ^2.26.1 => 2.32.0
gatsby-image: ^2.10.0 => 2.11.0
gatsby-plugin-layout: ^1.9.0 => 1.10.0
gatsby-plugin-manifest: ^2.11.0 => 2.12.0
gatsby-plugin-material-ui: ^2.1.10 => 2.1.10
gatsby-plugin-nprogress: ^2.9.0 => 2.10.0
gatsby-plugin-react-helmet: ^3.8.0 => 3.10.0
gatsby-plugin-sharp: ^2.13.0 => 2.14.0
gatsby-plugin-transition-link: ^1.20.5 => 1.20.5
gatsby-source-filesystem: ^2.10.0 => 2.11.0
gatsby-theme-material-ui: ^1.0.13 => 1.0.13
gatsby-transformer-sharp: ^2.11.0 => 2.12.0
npmGlobalPackages:
gatsby-cli: 2.19.0
Any ideas?
I started creating a minimal reproduction and adding everything back one by one, but decided to play more with my first setup for a little...and I'm glad I did.
Here's what caused the issue:
This Gatsby install is part of a Project Template we use which includes backend code, front-end, pipeline deployment scripts, etc.
The structure is similar to:
ProjectTemplate folder
client folder
server folder
other folders
The Gatsby install lives in the client folder but occasionally I need to go into the root folder to do certain things.
So what happened!?
I accidentally installed gatsby-source-graphql into the root folder instead of the client folder. That's all.
I should have picked this up when I ran gatsby info --clipboard as it's clearly not listed as a dependency.

Angular Testing - Using Jest with Protractor

I am new to Angular testing, and I want to perform 2 kinds of test for my application:
Unit Test - I choose to use Jest since I can run my test without opening the browser, and it also supports testing for specific cases with --testNamePatern.
End to end test - I want to try out Protractor since it is available in Angular and also has a big Angular community to work with.
My question is, can I use both Jest and Protractor in my application? If yes, do I need to configure anything to use both of them in my application.
You can use both jest and protractor in your application. By default the new angular cli release gives you a karma runner for unit tests and a protractor runner for end to end tests inside the same application. You are just changing Karma with Jest.
Can I run protractor tests (end to end) with jest?
No you cannot.
Can I run unit tests using protractor?
No you cannot.
Can I run protractor for end to end tests and jest for unit tests in the same application?
Yes you can. You will just need to tell jest which files to pick up and the same with protractor.
Can I get both the reports in a single file or a single run?
No you cannot. You will have to configure your jest runner to print reports which will be different from the protractor reports.
You can use both jest and protractor without configuring anything special. Here is a snippet of the package.json I am using for running e2e tests with protractor and lighthouse tests with jest.
{
"name": "performance-tests",
"version": "1.0.0",
"description": "Performance tests and end to end tests.",
"main": "jest.js",
"scripts": {
"debug": "node --inspect-brk ./node_modules/.bin/protractor protractor.conf.js",
"pretest": "npm run tsc && npm run webdriver-update",
"e2e": "npm run tsc && ./node_modules/protractor/bin/protractor protractor/compiled-js-files/protractor.conf.js",
"grid": "sh run-grid.sh && npm run e2e",
"tsc": "./node_modules/typescript/bin/tsc",
"webdriver-update": "./node_modules/protractor/bin/webdriver-manager update --standalone --versions.standalone=3.8.0 --chrome --versions.chrome=78.0.3904.97",
"lighthouse": "./node_modules/jest/bin/jest.js --verbose -t=lighthouse",
"lighthouse-reports": "./node_modules/jest/bin/jest.js --verbose -t=lighthouse && node ./lighthouse/db.js"
},
"repository": {
"type": "",
"url": ""
},
"author": "Sankalan Parajuli",
"license": "ISC",
"bugs": {
"url": ""
},
"homepage": "",
"dependencies": {
"#types/jasmine": "^3.3.12",
"#types/jasminewd2": "^2.0.6",
"#types/node": "^12.12.14",
"jasmine": "^3.3.1",
"lighthouse": "^4.0.0-beta",
"protractor": "5.4.2",
"protractor-beautiful-reporter": "^1.3.3"
},
"devDependencies": {
"#types/request": "^2.48.3",
"#types/selenium-webdriver": "^4.0.0",
"csvtojson": "^2.0.8",
"jest": "^23.4.1",
"moment": "^2.24.0",
"mongodb": "^3.1.13",
"puppeteer": "^1.6.0",
"request-promise": "^4.2.5",
"ts-node": "^8.5.2",
"typescript": "2.8.1"
}
}
Hope it helps.

Why does Babel throw Unknown option: ... Children?

Trying to run build on CircleCi and it's failing on test. Same stuff is working perfect on my local.
My .babelrc config:
{
"presets": [
"es2015",
"react",
"stage-2"
],
"plugins": [
"transform-class-properties",
"react-hot-loader/babel",
["babel-plugin-transform-builtin-extend", {
"globals": ["Error", "Array"]
}],
["transform-runtime", {
"polyfill": false,
"regenerator": true
}]
]
}
Error I'm getting from circleCI:
yarn test v0.27.5
$ jest
FAIL src/utils/service-helper.test.js
● Test suite failed to run
ReferenceError: [BABEL] /home/circleci/repo/src/utils/service-helper.test.js: Unknown option: /home/circleci/repo/node_modules/react/index.js.Children. Check out http://babeljs.io/docs/usage/options/ for more information about options.
A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:
Invalid:
`{ presets: [{option: value}] }`
Valid:
`{ presets: [['presetName', {option: value}]] }`
Any idea what is going on as the same configuration is working on another project
The error is unhelpful, but the issue is that your config has react in the preset list, but it can't find the babel-preset-react module in your node_modules, so instead it is loading the react module itself as if it were a preset. But since the "react" module isn't a preset, Babel throws.
Most likely, you've forgotten to list babel-preset-react in your package.json.

BrowserStack + Protractor getting the name of the tests to show up as session ID

I know that you could use browserstack before protractor 3.0 but they have added official support in 3.0 . I haven't been able to try that out yet so maybe that's the answer to my question? Currently don't have the ability to upgrade so if that's my answer then I will go through the proper channels to make that happen.
The problem I'm having with browser stack is that it names all the sessions random hashes. So I may have a suite of tests and I have no way to tell which session is which test. You can manually change the capabilities.name but then everything will have that name.
I know when I use saucelabs it will name everything after the name of the test file. so for example it will be sometest.js . I don't know if this is something protractor is doing or some node-module we're using that is doing the work behind the scenes and I don't know?
I just want to know how I can run my suite that runs all my smoketests and names each browserstack session after the actual name of the tests in the suite.
here is an example of what things look like on browserstack. I did manually set the capabilities.name to mytest for a few sessions.
here is how they look with sauce labs
Also here is my package.json file in case any of these modules might be making saucelabs name the jobs after the test file name
{
"name": "protractor",
"version": "1.0.0",
"description": "Protractor protype",
"main": "Gruntfile.js",
"dependencies": {
"grunt-sauce-tunnel": "^0.2.1",
"jasmine-reporters": "^2.1.1",
"lodash": "^3.2.0",
"protractor": "2.5.1",
"require-all": "2.0.0"
},
"devDependencies": {
"chalk": "^1.1.1",
"grunt": "^0.4.5",
"grunt-env": "^0.4.2",
"grunt-protractor-runner": "3.0.0",
"grunt-sauce-connect-launcher": "^0.3.0",
"jasmine-spec-reporter": "^2.2.3",
"request-promise": "^1.0.2",
"selenium-webdriver": "2.48.2",
"xlsx-json": "^0.1.0"
},
"scripts": {
"install": "node node_modules/protractor/bin/webdriver-manager update",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git:user/rwolfe/protractor"
},
"author": "",
"license": "ISC"
}
So I don't know if this was due to upgrading to protractor 3.0 or not but apparently in the conf.js I saw that for sauce labs we were setting
exports.config.capabilities.name = " ";
and when I did that for browserstack now the names of the test show up how I would expect as below.

Wintersmith: error Error loading plugin './node_modules/wintersmith-coffee/': Cannot find module './plugin'

I built a site with wintersmith in November of 2013. It's live at http://powma.com
I'm coming back to it, but it's not building :-{
I don't mind getting my hands dirty, but I don't know where to start. I'm getting this error:
error Error loading plugin './node_modules/wintersmith-coffee/': Cannot find module './plugin'
Any suggestions?
Thanks!
Mike
UPDATE
Hey, this is because the coffeescript wasn't getting compiled.
I installed it globally, but that didn't help.
$ sudo npm install -g coffee-script
I manually compiled it and moved to other errors. Any suggestions for what's missing?
$ coffee -c plugin.coffee
Here's my config.json:
{
"locals":
{ "url": "http://localhost:8080"
, "title": "Powma"
, "subTitle": "Linking you to technology"
, "motto": "We build exceptions sites and applications to connect people to products, services, and each other."
, "owner": "Michael Cole"
, "profilePicture": "/static/img/profile-professional.jpg"
, "inlineSpriteMaxBytes" : 10000
},
"views": "./views",
"plugins":
[ "./node_modules/wintersmith-coffee/"
, "./node_modules/wintersmith-stylus/"
],
"require": {
"moment": "moment",
"_": "underscore",
"typogr": "typogr"
},
"jade": {
"pretty": true
},
"markdown": {
"smartLists": true,
"smartypants": true
},
"paginator": {
"perPage": 3
}
}
And package.json:
{
"name": "Powma-com",
"version": "0.1.1",
"private": true,
"engines": {
"node": "0.10.17"
},
"dependencies": {
"moment": "2.0.x",
"underscore": "1.5.x",
"typogr": "0.5.x",
"wintersmith": "2.0.x",
"wintersmith-stylus": "git://github.com/MichaelJCole/wintersmith-stylus.git#master",
"wintersmith-coffee": "0.2.x",
"express": "3.4.x",
"sendgrid": "~0.3.0-rc.1.7",
"express-validator": "~0.8.0",
"underscore-express": "0.0.4"
}
}
This is a new dev laptop I'm working with so that may be part of the problem.
I worked around the issue, but didn't fix it. Do I really need to manually compile the coffeescript?
Thanks!
I solved this issue by explicitly specifying plugin.coffee in the config.json file.
{
...other stuff...
"plugins":
[ "./node_modules/wintersmith-coffee/plugin.coffee"
, "./node_modules/wintersmith-stylus/plugin.coffee"
],
...more stuff...
}
It looks like you're missing wintersmith-coffee in node_modules; make sure you have it installed locally with npm install wintersmith-coffee. You can also try removing it from config.json if you're not using it anywhere.
It would also be helpful to see both your config.json and package.json. Also make sure you run an npm install and npm update to make sure you have everything referenced in package.json installed and updated.
Update
Not having CoffeeScript installed could have been the issue. After installing that globally, I'm not sure if all of your shell sessions will pick up the command and use it without being restarted. With a new shell session, see if you can build the site. You can also try testing Wintersmith in isolation of your site. Try generating a sample site with wintersmith new somepath and see if you can run wintersmith build there. That would be a good start for narrowing down your issues between your site and your workstation setup.