Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Issue with feathers-authentication #512

Closed
nanomag opened this issue May 17, 2017 · 5 comments
Closed

Issue with feathers-authentication #512

nanomag opened this issue May 17, 2017 · 5 comments

Comments

@nanomag
Copy link

nanomag commented May 17, 2017

Hi,

I've created a new project with the last stable version of feathers and everything works perfectly except when I install feathers-authentication. It raise these errors:

ERROR in ./~/joi/lib/string.js
Module not found: Error: Can't resolve 'net'
@ ./~/joi/lib/string.js 3:10-24
 @ ./~/joi/lib/index.js
 @ ./~/jsonwebtoken/sign.js
 @ ./~/jsonwebtoken/index.js
 @ ./~/feathers-authentication/lib/utils.js
 @ ./~/feathers-authentication/lib/passport/initialize.js
 @ ./~/feathers-authentication/lib/passport/index.js
 @ ./~/feathers-authentication/lib/index.js

ERROR in ./~/isemail/lib/isemail.js
Module not found: Error: Can't resolve 'dns'
@ ./~/isemail/lib/isemail.js 45:10-24
 @ ./~/isemail/index.js
 @ ./~/joi/lib/string.js
 @ ./~/joi/lib/index.js
 @ ./~/jsonwebtoken/sign.js
 @ ./~/jsonwebtoken/index.js
 @ ./~/feathers-authentication/lib/utils.js
 @ ./~/feathers-authentication/lib/passport/initialize.js
 @ ./~/feathers-authentication/lib/passport/index.js
 @ ./~/feathers-authentication/lib/index.js

Does anyone know what could be happening? Should I use a previous version or what other option could apply?

Note: I have another project that's working perfectly with feathers-authentication@0.7.12. In this new project, I have installed feathers-authentication@1.2.3 (I've tested with versions higher than 1.0 and not works).

@snewell92
Copy link

Does it give you an error after you npm install feathers-authentication?
If so that's super strange.

Can you post your package.json? (just dependencies/dev-dependencies)
Firstly, try removing your node_modules folder and doing a clean npm install.

Otherwise, can you post a repo or at least your default.json and any other relevant configuration? If you are able, can you debug (If using VScode you can use a node, launch configuration to debug) and get to where it throws the error (is it when your are requiring authentication, or calling a method?)?

@nanomag
Copy link
Author

nanomag commented May 17, 2017

Hi @snewell92, thanks for your help.

FYI, I'm using yarn instead of npm. And feathers-authentication installation does not generate errors.
Also, I've removed my node_modules and installed it again but the issue persists.

The issue is raised when I run yarn dev (webpack -d --watch). I'm trying to generate the bundle.js that handles my React setup.

This is my default.json:

{
  "name": "__",
  "description": "__",
  "version": "0.0.0",
  "homepage": "",
  "main": "src",
  "keywords": [
    "feathers"
  ],
  "author": {
    "name": "__",
    "email": "__"
  },
  "contributors": [],
  "bugs": {},
  "directories": {
    "lib": "src"
  },
  "engines": {
    "node": ">= 6.0.0",
    "yarn": ">= 0.18.0"
  },
  "scripts": {
    "dev": "webpack -d --watch",
    "build": "webpack -p",
    "test": "npm run eslint && npm run mocha",
    "eslint": "eslint src/. test/. --config .eslintrc.json",
    "start": "node src/",
    "mocha": "mocha test/ --recursive"
  },
  "dependencies": {
    "body-parser": "^1.17.1",
    "compression": "^1.6.2",
    "cors": "^2.8.3",
    "eslint": "^3.19.0",
    "feathers": "^2.1.2",
    "feathers-authentication": "^1.2.3",
    "feathers-authentication-hooks": "^0.1.3",
    "feathers-authentication-jwt": "^0.3.1",
    "feathers-authentication-local": "^0.3.4",
    "feathers-configuration": "^0.4.1",
    "feathers-errors": "^2.8.0",
    "feathers-hooks": "^2.0.1",
    "feathers-hooks-common": "^3.3.2",
    "feathers-nedb": "^2.6.2",
    "feathers-rest": "^1.7.2",
    "feathers-socketio": "^2.0.0",
    "helmet": "^3.6.0",
    "joi": "^10.4.2",
    "joi-browser": "^10.0.6",
    "mocha": "^3.3.0",
    "nedb": "^1.8.0",
    "react": "^15.5.4",
    "react-dom": "^15.5.4",
    "react-redux": "^5.0.4",
    "react-router": "^4.1.1",
    "react-router-redux": "^4.0.8",
    "redux": "^3.6.0",
    "request": "^2.81.0",
    "request-promise": "^4.2.1",
    "semantic-ui-react": "^0.68.3",
    "serve-favicon": "^2.4.2",
    "winston": "^2.3.1"
  },
  "devDependencies": {
    "babel-core": "^6.24.1",
    "babel-loader": "^7.0.0",
    "babel-polyfill": "^6.23.0",
    "babel-preset-env": "^1.4.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "css-loader": "^0.28.1",
    "json-loader": "^0.5.4",
    "style-loader": "^0.17.0",
    "webpack": "^2.5.1"
  }
}

@nanomag
Copy link
Author

nanomag commented May 18, 2017

I fixed the issue adding to webpack.config.js:

node: {
    net: 'empty',
    tls: 'empty',
    dns: 'empty'
}

and webpack runs correctly now.

Unfortunately, I get a error trying to load the initial page in the browser:

Uncaught TypeError: Cannot read property 'prototype' of undefined
    at Function.exports.__monkeypatchNode (eval at <anonymous> (bundle.js:7694), <anonymous>:33:23)
    at module.exports (eval at <anonymous> (bundle.js:7694), <anonymous>:21:11)
    at Authenticator.init (eval at <anonymous> (bundle.js:16239), <anonymous>:30:69)
    at new Authenticator (eval at <anonymous> (bundle.js:16239), <anonymous>:21:8)
    at eval (eval at <anonymous> (bundle.js:16261), <anonymous>:13:28)
    at Object.<anonymous> (bundle.js:16261)
    at __webpack_require__ (bundle.js:20)
    at eval (eval at <anonymous> (bundle.js:13408), <anonymous>:20:17)
    at Object.<anonymous> (bundle.js:13408)
    at __webpack_require__ (bundle.js:20)

The error comes from connect.js:33.

This error is related to passport library and the issue seems to be related to a missing passport instance: jaredhanson/passport#546 (comment)

I found a resource where they are trying to fix the issue but I'm not sure how to handle the situation because the passport instance issue should be feathers-authentication library.

I'd really appreciate your help.

@nanomag
Copy link
Author

nanomag commented May 18, 2017

I found the issue, it was a problem in my feathers-client setup.

I was using import authentication from 'feathers-authentication'; and the new version use import authentication from 'feathers-authentication-client';

@snewell92
Copy link

Glad you solved it!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants