Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`node-fetch@2.0.0-alpha.6` throws error "Cannot find module 'encoding'" #316

Closed
TooTallNate opened this issue Jul 24, 2017 · 8 comments
Closed

Comments

@TooTallNate
Copy link
Contributor

@TooTallNate TooTallNate commented Jul 24, 2017

$ npm ls
t@1.0.0 /Users/nrajlich/t
└── node-fetch@2.0.0-alpha.6

$ node -e "require('node-fetch')"
module.js:487
    throw err;
    ^

Error: Cannot find module 'encoding'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/nrajlich/t/node_modules/node-fetch/lib/index.js:13:16)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

alpha.5 works as expected.

@bitinn

This comment has been minimized.

Copy link
Collaborator

@bitinn bitinn commented Jul 25, 2017

You need to manually install encoding, that's all. We decouple it from dependency list, as only body.textConverted() use it, and it's a non-spec extension for back-compat with v1 text().

Also sorry for the trouble, v2 alpha is in flux at the moment (eg. breaking changes might still come), I am thinking about safer ways to release v2 alpha, so suggestions are welcomed!

See #228 #252

@bitinn

This comment has been minimized.

Copy link
Collaborator

@bitinn bitinn commented Jul 25, 2017

Also my result from a plain install:

$ npm install node-fetch@next
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN test@1.0.0 No description
npm WARN test@1.0.0 No repository field.

+ node-fetch@2.0.0-alpha.6
added 1 package in 4.038s
@bitinn

This comment has been minimized.

Copy link
Collaborator

@bitinn bitinn commented Jul 25, 2017

Oh wait I misread your problem. We do tested for without encoding scenario in Travis CI, I have to double check again then...

@TooTallNate

This comment has been minimized.

Copy link
Contributor Author

@TooTallNate TooTallNate commented Jul 25, 2017

Sure it installs, but did you try requiring it?

@bitinn

This comment has been minimized.

Copy link
Collaborator

@bitinn bitinn commented Jul 25, 2017

Yes I am working on fixing this, I don't understand how it happens really. Give me a few minutes

@bitinn

This comment has been minimized.

Copy link
Collaborator

@bitinn bitinn commented Jul 25, 2017

alpha 7 release should have fixed this

@bitinn bitinn closed this Jul 25, 2017
@bitinn

This comment has been minimized.

Copy link
Collaborator

@bitinn bitinn commented Jul 25, 2017

And a brief summary on why it could have happened:

  • I was testing another feature which require me to be on node v5
  • v5 use npm v3, which doesn't run npm prepare by default when you publish
  • and somehow in my local repo there is an older copy of index.js and index.es.js
  • so while I am on the alpha.6 branch, the published package still contains an older version of node-fetch v2...
@TooTallNate

This comment has been minimized.

Copy link
Contributor Author

@TooTallNate TooTallNate commented Jul 25, 2017

alpha 7 works for me now. Thanks for the quick turnaround @bitinn!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.