Express.js using passport-facebook - TypeError: Object 302 has no method 'indexOf' - express

I've got an express project already running, I'm just trying to hook it up using passport to authenticate through facebook, I've basically copied the example from the github page here:
https://github.com/jaredhanson/passport-facebook
But I'm getting the following error whenever I try to go to the '/auth/facebook' URL in my app:
TypeError: Object 302 has no method 'indexOf'
at ServerResponse.res.redirect (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/response.js:546:13)
at Strategy.strategy.redirect (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport/lib/middleware/authenticate.js:294:15)
at Strategy.OAuth2Strategy.authenticate (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport-facebook/node_modules/passport-oauth2/lib/strategy.js:227:10)
at Strategy.authenticate (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport-facebook/lib/strategy.js:84:41)
at attempt (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport/lib/middleware/authenticate.js:337:16)
at authenticate (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport/lib/middleware/authenticate.js:338:7)
at callbacks (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:171:11)
at param (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:145:11)
at pass (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:152:5)
at Router._dispatch (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:179:5)

It could be an incompatibility with older versions of express; you might try updating to express#3.5.x; 3.6 and above deprecated some methods and the refactor might not be worth it.
Try npm install express#3.5.x, or npm install express#3.5.x -g if it's a global package. Make sure to update the package.json file too.

Related

ES6 import and npm packages

Anyone got a link to documentation explaining exactly how ES6 import is supposed to work with npm packages (as opposed to javascript module files) ?
Also (and possibly related) a link to documentation on the use/significance of "module" as a top-level key in an npm package.json file ?
Eg. consider the following from juggle/resize-observer ;
package.json
{
...
"module": "lib/exports/resize-observer.js",
...
}
consumer javascript file
import { ResizeObserver } from '#juggle/resize-observer';
On the above import Chrome sends a request to the server for '#juggle/resize-observer' which is a directory..... so what happens next ? (I don't have a working instance of this and my server doesn't return anything yet as I don't know what it's supposed to / in what format ). Is this syntax only for use with some sort of build tool where it ultimately gets replaced with the actual file ?
I have looked at the npm site/googled and cannot find any relevant documentation.
UPDATE Still waiting for a link to relevant documentation (no relevant Google results at this time) but for anyone asking the same question: apparently you need your server to do "module resolution" . Alternatively you can use Snowpack or a bundler eg. Webpack.
Apparently npm/node packages are not packaged with browsers in mind or based on any W3C/Web Modules standard specification.
See here for module resolution info.
So at present to use an npm package in a browser you must do one of the following
use a bundler like webpack
use snowpack
use a CDN which resolves the module request
implement npm module resolution in your own server
Find the package entry point and use that in your ES6 import statement.
However, if the package's json "main" property changes in a subsequent update you
will need to update your code to reflect this.

How to fix relative module error for a newly created nuxt.js app with starter template?

I tried to create a nuxt app with the guide from the official website, chose default options because I wanted the starter template but on running npm run dev, I keep encountering the error:
This relative module was not found:
* ./components/nuxt-error.vue in ./.nuxt/index.js
I've tried searching about it but I couldn't find any useful resource/fix. I've also tried vue init nuxt-community/starter-template for the installation but I still get the same error.
Any fixes?
So I found a solution. I couldn’t figure out the error because the nuxt-error.vue file was actually imported correctly. Turns out “npm” installations have been giving me issues (had issues with TailwindCSS too).
So if you ever encounter this error on loading the base nuxt app, recreate the project using “yarn” instead. Works like magic!
This Error basically means, that in one of your files you are trying to import another file with the relative path of ./components/nuxt-error.vue but no file with this path exists.
However
I just read that vue init nuxt-community/starter-template is deprecated and no longer maintained. Instead of fixing this Error you should restart your project with npx create-nuxt-app <yourAppName>. https://github.com/nuxt-community/starter-template

Getting error "read ECONNRESET" while creating a new stenciljs project. How to fix the same?

I am trying to create a new stenciljs project using command npm init stencil. As soon as I choose a set up (whether app or component) and hit 'enter', a read ECONNRESET error is prompted.
I have tried updating the npm but nothing is working.
I expect the command prompt to show me the option where I can enter the project name after choosing a setup for my project but it throws an error, instead.
An ECONNRESET in npm means that npm is unable to connect to an URL where it's looking for dependencies or resources. In most cases, that means that your npm is unable to connect to the NPM Registry. But in your case it seems different.
You're trying to create a Stencil app, with npm init stencil. Under the hood, that That means you're using npm to download the create-stencil package and run it to generate the scaffold of your Stencil app.
The first part, getting the create-stencil package works well, the problem arrives while running the package. If I am correct, create-stencil tries to clone the stencil-app-starter GitHub repository and modify it. So maybe you're behind a corporate or university proxy, blocking GitHub, or another the URLs of the create-stencil resources, maybe the connection is rather flacky, maybe GitHub was done at that moment...

String functions not working in electron app

I have a .js file inside an electron app that uses the quasar framework.
inside this file i have axios to make requests to my api to pull data
once i get the response i use the data for further processing. However i need some string functions to escape some strings and when i try .replace it just fails.
var t = JSON.parse(JSON.stringify(someObj))
console.log(t.message.replace(/"/g, '\\"');)
the app just fails to build and tells me there is some error in x line. if i use console.log(t.message) i see that it print the text in the terminal console, so i know the value is not null.
Also when i hover my mouse over the variable it tells me (any) not sure what this means.
image:
P.S: this is my first time working this tech stack.
turned out there was a configuration issue with babel inside electron that was using quasar framework, it didn't not accept commonjs as module and hence no vanilla javascript would work.
Just had this issue myself, I know you've answered your own question but if you can use nodejs you can install replace-string from npm and use it
command: npm install replace-string
link:
https://www.npmjs.com/package/replace-string
This issue has literally caused me a morning of work - but hope someone finds this post and fixes this issue quicker!

Nuxt generate show error: Cannot read property 'normalModuleFactory' of undefined

Recently I upgrade Nuxt from 1.4.0 to 1.2.x and Vuetify from 1.0.9 to 1.2.x. After that npm run dev works fine. but when I run Nuxt generate I get below error. I am stuck on this error since last night and can't find any idea why it's occurring. Any guidance will be helpful. Thank in advance.
nuxt:build Generating files... +138ms
nuxt:build Generating routes... +13ms
nuxt:build Building files... +314ms
ERROR
TypeError: Cannot read property 'normalModuleFactory' of undefined
- IgnorePlugin.js:96 IgnorePlugin.apply
[vue]/[webpack]/lib/IgnorePlugin.js:96:18
- Tapable.js:375 Compiler.apply
[npm]/[nuxt]/[tapable]/lib/Tapable.js:375:16
- webpack.js:33 webpack
[npm]/[nuxt]/[webpack]/lib/webpack.js:33:19
- builder.js:524 compilers.compilersOptions.map.compilersOption
[npm]/[nuxt]/lib/builder/builder.js:524:24
- Array.map
- builder.js:523 Builder.webpackBuild
[npm]/[nuxt]/lib/builder/builder.js:523:39
- builder.js:168 Builder.build
[npm]/[nuxt]/lib/builder/builder.js:168:16
package.json can be find here.
nuxt.config.js can be found here.
I tried to dig about it, but it seems to be generated through webpack. So I updated to webpack 4 too. But still it's throwing this error.
If you need any more details, I would be happy to provide.
After a long talk with developer community of nuxtjs. Here is solution.
This problem occur when we try to run nuxt generate but our local nuxt version !== global nuxt version.
So solution is either update global nuxt version by npm i -g nuxt or run project from local nuxt version node_modules/.bin/nuxt generate