jimp-dev / jimp

An image processing library written entirely in JavaScript for Node, with zero external or native dependencies.
http://jimp-dev.github.io/jimp/
MIT License
14.04k stars 760 forks source link

0.3.3 : Cannot find module 'core-js/modules/es6.array.is-array' #543

Closed lonix1 closed 6 years ago

lonix1 commented 6 years ago

jimp 0.3.3 ubuntu 18

package.json:

{
  "name": "foo",
  "version": "0.0.1",
  "devDependencies": {
    "jimp": "0.3.3"
  }
}

app.js:

"use strict";
const jimp = require("jimp");

run it: node app.js

result is an error with: Error: Cannot find module 'core-js/modules/es6.array.is-array'

termax commented 6 years ago

same here

StanislawBorowy commented 6 years ago

Same here:

$ npm ls jimp
my-project@1.0.0 /Users/dev/git/my-project
└── jimp@0.3.3

$ npm -v
6.2.0

$ node -v
v10.8.0

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.13.6
BuildVersion:   17G65

Have no error when using Jimp v0.3.2 ...

hipstersmoothie commented 6 years ago

I'm having trouble reproducing this.

EDIT: nvm some other modules must have installed that on my test project :(

hipstersmoothie commented 6 years ago

Quick fix until next release:

yarn add @babel/polyfill
hipstersmoothie commented 6 years ago

Did my above fix help until a release can get out?

lonix1 commented 6 years ago

@hipstersmoothie I don't use yarn, so don't know if that works, sorry. But I downgraded to 0.3.2 which works for me.

hipstersmoothie commented 6 years ago

Can you verify the babel polyfill? you can instead just

npm i @babel/polyfill

npm i and yarn add are the same thing

lonix1 commented 6 years ago

@hipstersmoothie I tried that and it works. Might be useful for those using those tools, thanks.

I'll wait for the next version though.

hipstersmoothie commented 6 years ago

I'm gonna keep this open til a release happens

rumblefrog commented 6 years ago

Thought my node installation was broken, was going insane. Thanks for the quick release.

hipstersmoothie commented 6 years ago

I'm trying to get it release ASAP. But I don't have the key yet. In the meantime please install @babel/polyfill and jimp should work as expected

oliver-moran commented 6 years ago

I've published the release but the problem seems to be still there in 0.3.4.

screen shot 2018-08-11 at 21 39 11

This is from my smoke test as follows:

var Jimp = require("jimp");

// open a file called "lenna.png"
Jimp.read("lenna.png", function (err, lenna) {
    if (err) throw err;
    lenna.resize(256, 256)            // resize
         .quality(60)                 // set JPEG quality
         .greyscale()                 // set greyscale
         .write("lena-small-bw.jpg"); // save
});
hipstersmoothie commented 6 years ago

It got added as a dev dep so it wasn't installed 😢

johnnykramer commented 6 years ago

still Error: Cannot find module 'core-js/modules/es6.array.is-array'...

hipstersmoothie commented 6 years ago

I just pushed a commit that should resolve the issue. https://github.com/oliver-moran/jimp/commit/97ed2a524ea4263af2581dd20578f166d714fd34 @oliver-moran

johnnykramer commented 6 years ago

@hipstersmoothie sorry but still Error: Cannot find module 'core-js/modules/es6.array.is-array'

hipstersmoothie commented 6 years ago

@johnnykramer I know I think the above commit should fix the problem.

johnnykramer commented 6 years ago

@hipstersmoothie unfortunately, last commit didn't...

hipstersmoothie commented 6 years ago

My branch here seems to work. I ran

yarn add hipstersmoothie/jimp#test

and running the above code yields no errors.

johnnykramer commented 6 years ago
npm uninstall --save jimp
npm install --save hipstersmoothie/jimp#test

And still Error: Cannot find module 'core-js/modules/es6.array.is-array'

hipstersmoothie commented 6 years ago

did you rm -rf node_modules/

hipstersmoothie commented 6 years ago

@johnnykramer what version of node are you using?

johnnykramer commented 6 years ago

@hipstersmoothie

> node -v
> v8.11.3

yes, i've done rm -rf node_modules/

oliver-moran commented 6 years ago

I've published 0.3.5. Smoke test works again from my end.

I'm also using v8.11.3.

hipstersmoothie commented 6 years ago

I just tested with v8.11.3 also and it seems to work

hipstersmoothie commented 6 years ago

@johnnykramer can you test with v0.3.5 ?

johnnykramer commented 6 years ago

@oliver-moran @hipstersmoothie node v10.8.0 also Error: Cannot find module 'core-js/modules/es6.array.is-array'

hipstersmoothie commented 6 years ago

I can no longer reproduce the issue on any version of node. Could you throw a sample project together.

this is my setup right now:

{
  "name": "jimp-testing-project",
  "version": "1.0.0",
  "main": "src/index.js",
  "dependencies": {
    "jimp": "^0.3.5"
  }
}
var Jimp = require("jimp");

// open a file called "lenna.png"
Jimp.read("./exampleImages/lenna.png", function (err, lenna) {
    if (err) throw err;
    lenna.resize(256, 256)            // resize
         .quality(60)                 // set JPEG quality
         .greyscale()                 // set greyscale
         .write("lena-small-bw.jpg"); // save
});
nvm use 10.8.0
rm -rf node_modules  
npm i --save jimp@0.3.5
node src/index.js
johnnykramer commented 6 years ago

@hipstersmoothie

{
  "name": "test-project",
  "version": "1.0.0",
  "main": "index.js",
  "dependencies": {
    "jimp": "^0.3.5"
  }
}
const jimp = require('jimp');

async function saveImage(imageData, outputPath) {
  jimp.read(imageData)
    .then(img => img.write(outputPath));
}
hipstersmoothie commented 6 years ago

@johnnykramer still no problems. can you check in node_modules for @babel/polyfill? the issue is that should be in node modules to supply the core-js polyfills. @babel/polyfill should also be a dependency in jimp

hipstersmoothie commented 6 years ago

maybe its a lock file problem? try deleting any of those if you have them

johnnykramer commented 6 years ago

@hipstersmoothie yes, @babel/polyfill present in the jimp's dependencies

hipstersmoothie commented 6 years ago
screen shot 2018-08-11 at 3 28 51 pm
hipstersmoothie commented 6 years ago

can i see the full stack trace?

hipstersmoothie commented 6 years ago

core-js is in node modules too?

johnnykramer commented 6 years ago
> test-app@1.0.0 start /home/ec2-user/environment/test-app
> node index.js

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'core-js/modules/es6.array.is-array'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/ec2-user/environment/test-app/node_modules/jimp/dist/index.js:3:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-app@1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test-app@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!     /home/ec2-user/.npm/_logs/2018-08-11T22_41_35_169Z-debug.log

core-js also installed. @hipstersmoothie

hipstersmoothie commented 6 years ago

Okay I'm a little baffled. I can't reproduce this at all. Is this within a AWS instance?

hipstersmoothie commented 6 years ago

The dependancies are installed so I don't know why it can't resolve them...

hipstersmoothie commented 6 years ago

does it work if you add @babel/polyfill or core-js directly?

hipstersmoothie commented 6 years ago

How about what npm version are you using?

hipstersmoothie commented 6 years ago

If you are on npm@2 it could be a problem https://github.com/babel/babel-preset-env/issues/162

I get the same issue when i am using npm < 3

johnnykramer commented 6 years ago

it is cloud9 on the aws ec2 instance. npm v6.2.0

johnnykramer commented 6 years ago

And i've installed @babel/polyfill and core-js manually — still not working! :(

hipstersmoothie commented 6 years ago

I have no experience with aws. You have any ideas? I'll search around for similar issues

hipstersmoothie commented 6 years ago

you definitely have core-js/modules/es6.array.is-array installed and babel is for sure trying to include it. maybe you could globally install it on the instance? (I'm just taking guesses at this point)

johnnykramer commented 6 years ago

@hipstersmoothie @oliver-moran problem has been solved! npm i -s core-js@2.5.7 I've installed specific 2.5.7 core-js version and jimp works well :) core-js v3 throws error as above.

hipstersmoothie commented 6 years ago

Awesome!

hipstersmoothie commented 6 years ago

now to figure out why core-js 3 was being installed

hipstersmoothie commented 6 years ago

I'm looking at the lock file and see no reference to core-js v3

hipstersmoothie commented 6 years ago

So on a clean install it defaults to core-js@3-ish?