mxgraph icon indicating copy to clipboard operation
mxgraph copied to clipboard

mxgraph 3.7.5 js not installing via npm

Open nigel-daniels opened this issue 9 years ago • 12 comments

I am using macOS Sierra 10.12.6, with node 8.4.0 and npm 5.3.0, when installing mxgraph using:

$npm -S install mxgraph

I get the following error:

npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

> [email protected] install /Users/Nigel/git/mxtest/public/js/node_modules/fsevents
> node install

[fsevents] Success: "/Users/Nigel/git/mxtest/public/js/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> [email protected] postinstall /Users/Nigel/git/mxtest/public/js/node_modules/mxgraph
> grunt build

Loading "Gruntfile.js" tasks...ERROR
>> TypeError: Cannot read property 'map' of null
Warning: Task "build" not found. Use --force to continue.

Aborted due to warnings.
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! [email protected] postinstall: `grunt build`
npm ERR! Exit status 3
npm ERR! 
npm ERR! Failed at the [email protected] postinstall 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!     /Users/Nigel/.npm/_logs/2017-09-07T00_20_45_100Z-debug.log

I have attached the associated log file too. Nb: I changed the .log to .txt to enable the upload.

2017-09-07T00_20_45_100Z-debug.txt

nigel-daniels avatar Sep 07 '17 21:09 nigel-daniels

Hwo did you solve the problem? I'm facing the same on Windows.

newlukai avatar Sep 15 '17 13:09 newlukai

Same problem, would be amazing if you could share your solution.

julvo avatar Oct 13 '17 16:10 julvo

I closed this as it was a duplicate of issue #83, sadly the files needed to implement a fix are not in the git hub repo.

nigel-daniels avatar Oct 13 '17 20:10 nigel-daniels

What files are missing?

davidjgraph avatar Oct 13 '17 20:10 davidjgraph

I could not locate the Grunt files or package.json, etc that were causing the problem during the npm install. I think @NicCOConnor has a fork that may contain a fix (See #83 ). Could that fix be pulled into the main branch then mxgraph will work via npm at the latest versions?

nigel-daniels avatar Oct 13 '17 20:10 nigel-daniels

I've pushed https://github.com/jgraph/mxgraph/tree/master/etc/build , is that what's needed?

davidjgraph avatar Oct 14 '17 13:10 davidjgraph

So I've tried the following: I cloned the repo, copied the build files into the repo base directory, renamed mxgraph-package.json to package.json, edited the @VERSION@ to be a version number (3.7.6). I than ran npm install in the repo base directory and everything ran, followed by a successful run of grunt. So I could not recreate the error with the current version when I try and use npm to pull it onto a different project. Are these build files the same ones that the current npm install package uses? If they differ can these replace the ones npm is using as they appear to work?

nigel-daniels avatar Oct 14 '17 22:10 nigel-daniels

@davidjgraph I think the issue here is that npm is expecting package.json and Gruntfile.js to be in the root in order to install directly from the source. The Gruntfile.js could possibly be in a build folder but I think package.json must stay in the root of the repo. I can update my fork to the latest version and create a pull request. But was unsure how you would feel about adding files to the root of the repo. Still, with this library picking up steam, I think it could be valuable.

NicCOConnor avatar Oct 18 '17 12:10 NicCOConnor

Nigel, yes, they are current files used when we call npm publish in the deploy step.

Just looking at the deploy process the Gruntfile and package.json are copied to the staging area root before calling npm publish. We're saying leaving them in the root fixes this problem? That's not a problem in Github. We're not fans of masses in the root folder, but, as you can tell, Github isn't the master repo, we can keep that clean.

# Publish to NPM
sed "s/@VERSION@/$DOTVERSION/" $BUILD/../etc/build/mxgraph-package.json > tmp/mxgraph/package.json
cp -v $BUILD/../etc/build/Gruntfile.js tmp/mxgraph/
npm publish tmp/mxgraph --access public
rm -rf tmp/mxgraph/package.json
rm -rf tmp/mxgraph/Gruntfile.js

I can just remove the last two lines from the deploy script if that's what's needed?

davidjgraph avatar Oct 18 '17 12:10 davidjgraph

@davidjgraph so it appears that the Gruntfile.js and package.json are in the root of the npm package npm install --force --save mxgraph They are correct. However, the Gruntfile seeks to build the library based on the include commands of the mxClient.js file. located at javascript/

mxClientContent = fs.readFileSync(
  path.join(__dirname, "./javascript/src/js/mxClient.js"),
  "utf8"
);
deps = mxClientContent.match(/mxClient\.include\([^"']+["'](.*?)["']/gi).map(function (str) {
  return "." + str.match(/mxClient\.include\([^"']+["'](.*?)["']/)[1];
});

prior to 3.7.2 this folder contained the individual mxGraph files and grunt packaged them into a single distributable. It would appear that in 3.7.3 the javascript/src/js/ folder contains a single mxClient.js file that is already minified. So the grunt process fails. Perhaps the Gruntfile now needs to just move that file into the dist folder and rename it to build.js where the package.json is looking for its main entry point "main": "./javascript/dist/build.js",

Nic

NicCOConnor avatar Oct 18 '17 13:10 NicCOConnor

@davidjgraph is it possible to fold in the code @NicCOConnor has done under #116? It looks like it would get the npm install working again 👍

nigel-daniels avatar Nov 10 '17 04:11 nigel-daniels

hey @davidjgraph, I see you've taken some steps towards solving these issues with the NPM build, but the published NPM version is still outdated and breaking on install. Could you look into it please?

aputhin avatar Dec 14 '17 18:12 aputhin