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

mxgraph 3.7.5 js not installing via npm #102

Closed
nigel-daniels opened this issue Sep 7, 2017 · 12 comments
Closed

mxgraph 3.7.5 js not installing via npm #102

nigel-daniels opened this issue Sep 7, 2017 · 12 comments

Comments

@nigel-daniels
Copy link

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 minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

> fsevents@1.1.2 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

> mxgraph@3.7.5 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! mxgraph@3.7.5 postinstall: `grunt build`
npm ERR! Exit status 3
npm ERR! 
npm ERR! Failed at the mxgraph@3.7.5 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 nigel-daniels changed the title mxgraph 3.7.5 js not installing via nom mxgraph 3.7.5 js not installing via npm Sep 7, 2017
@newlukai
Copy link

newlukai commented Sep 15, 2017

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

@julvo
Copy link

julvo commented Oct 13, 2017

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

@nigel-daniels
Copy link
Author

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.

@davidjgraph
Copy link
Contributor

What files are missing?

@nigel-daniels
Copy link
Author

nigel-daniels commented Oct 13, 2017

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?

@davidjgraph
Copy link
Contributor

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

@nigel-daniels
Copy link
Author

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?

@davidjgraph davidjgraph reopened this Oct 18, 2017
@NicCOConnor
Copy link
Contributor

@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.

@davidjgraph
Copy link
Contributor

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?

@NicCOConnor
Copy link
Contributor

NicCOConnor commented Oct 18, 2017

@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

@nigel-daniels
Copy link
Author

@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 👍

@aputhin
Copy link

aputhin commented Dec 14, 2017

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?

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

6 participants