IanVS / eslint-nibble

Ease into ESLint, by fixing one rule at a time
MIT License
787 stars 29 forks source link

Error: Cannot find module 'babel/polyfill' #6

Closed cmalard closed 9 years ago

cmalard commented 9 years ago

Hello,

Babel is actually required to run eslint-nibble, so it fails if Babel is not installed with this error :

module.js:338
    throw err;
          ^
Error: Cannot find module 'babel/polyfill'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/.../my-project/node_modules/eslint-nibble/index.js:4:1)
    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 Function.Module.runMain (module.js:501:10)
IanVS commented 9 years ago

What version of Eslint-nibble are you using? In recent versions I am precompiling, so babel should not be required at all.

cmalard commented 9 years ago

Latest, 0.1.0 :-)

cmalard commented 9 years ago

The file https://github.com/IanVS/eslint-nibble/blob/master/index.js make a call to

require("babel/polyfill");
IanVS commented 9 years ago

Ah ha. I must have missed that when I transitioned from using the Babel require hook to precompiling. Thanks for the catch!

I can't make a fix until tonight, is there any chance you can submit a PR to remove that line and the commented-out line above it? To test, you can npm link in the eslint-nibble directory, and then npm link eslint-nibble inside a project folder for symlinking into that project.

IanVS commented 9 years ago

Are people still seeing this error? It's the top visited page in the repo.

jeroenpelgrims commented 9 years ago

@IanVS I came here through Google because of the line "Cannot find module 'babel/polyfill'". It's unrelated to your library but is one of the top Google results for that error.

OliDow commented 8 years ago

Aye, I found it through a Google search also "Error: Cannot find module 'babel/polyfill'"

Oli

brajeshyadav84 commented 8 years ago

to resolve this need to run below npm install

npm install --save-dev babel-polyfill

basickarl commented 8 years ago

@brajeshyadav84 Still getting the error even when it is installed.

Any quick fixes?

IanVS commented 8 years ago

@basickarl is the error coming from eslint-nibble? Can you please post the error's stack trace?

basickarl commented 8 years ago

@IanVS Here ya go bud. Most likely babel.

karl@karl-ux303ln:~/dev/sketch/experiment/socketio$ node src/start-app.js 
module.js:442
    throw err;
    ^

Error: Cannot find module 'babel-core/polyfill'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/karl/dev/sketch/experiment/socketio/src/start-app.js:3:1)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)

package.json

...
  "devDependencies": {
    "babel-polyfill": "^6.13.0",
    "babel-preset-es2015": "^6.13.2",
    "babel-preset-stage-3": "^6.11.0",
    "babel-register": "^6.11.6",
...

start-app.js

require('babel-core/polyfill');
require('babel-core/register');

require('./app');

I did however fix the error by replacing require('babel-core/polyfill'); with require('babel-polyfill');. So if anyone else ends up here (babel related or eslint-nibble related), hope this helps.

This thread also helped: http://stackoverflow.com/a/33568284/1137669 apparantly it has changed in v6 as stated.

IanVS commented 8 years ago

This is not related to this package. But, it looks like you've installed babel-polyfill but are trying to require polyfill from babel-core. I believe you need to change your require to require('babel-polyfill'). Same for babel-register as well.

On Sat, Sep 3, 2016, 11:53 Karl Morrison notifications@github.com wrote:

@IanVS https://github.com/IanVS Here ya go bud.

karl@karl-ux303ln:~/dev/sketch/experiment/socketio$ node src/start-app.js module.js:442 throw err; ^

Error: Cannot find module 'babel-core/polyfill' at Function.Module._resolveFilename (module.js:440:15) at Function.Module._load (module.js:388:25) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at Object. (/home/karl/dev/sketch/experiment/socketio/src/start-app.js:3:1) at Module._compile (module.js:541:32) at Object.Module._extensions..js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3)

package.json

... "devDependencies": { "babel-polyfill": "^6.13.0", "babel-preset-es2015": "^6.13.2", "babel-preset-stage-3": "^6.11.0", "babel-register": "^6.11.6", ...

start-app.js

require('babel-core/polyfill'); require('babel-core/register');

require('./app');

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/IanVS/eslint-nibble/issues/6#issuecomment-244554158, or mute the thread https://github.com/notifications/unsubscribe-auth/AEZyAXHkgAnWA3lCx8ZezIiX-zSnVzdlks5qmZfdgaJpZM4FVPvi .

nywooz commented 6 years ago
  1. to resolve this, i ran the line below npm install --save-dev babel-polyfill

  2. Then, I imported the file in my main entry "App.js". require("babel-polyfill");

If you are not not, try navigating you "node_modules" folder and search for "node_modules\babel-polyfill"

lloydbanks commented 5 years ago

Strings below helped me to solve the issue

npm install --save @babel/polyfill
import "@babel/polyfill";

Note that it should be installed as a dependency, not a devDependency (because it runs before our source code). And a @ symbol should be present for the last babel version.

IanVS commented 5 years ago

@lloydbanks and @nywooz are you having this error when using eslint-nibble? If so, would you mind please opening another issue? Otherwise, I think as mentioned above this issue is ranking on Google and drawing in folks having issues in other projects. For that reason I'm going to lock this thread. But if you've come here from Google, you might as well check out what eslint-nibble can do for you, and maybe it'll be useful. :)