MathJax-src icon indicating copy to clipboard operation
MathJax-src copied to clipboard

How do I build this project myself

Open weifu6 opened this issue 1 year ago • 4 comments

I want to build this project on my computer, I installed all the dependencies, tried to run “npm run make-components”, but there is no way to build it correctly.

weifu6 avatar Jun 28 '24 09:06 weifu6

Did you

npm run compile

first?

If so, then what error message are you getting, or what is going wrong when you try to make the components? You don't give enough information to begin to diagnose you situation.

dpvc avatar Jun 28 '24 13:06 dpvc

I had run "npm run compile" first,my step is:

npm install
npm run compile
npm run make-components

my error is:

D:\git\mathjax>npm run make-components

> [email protected] premake-components
> npm run --silent clean:es5 && npm run --silent clean:lib


> [email protected] make-components
> cd components && node bin/makeAll src

Building \src\a11y\assistive-mml
node:internal/modules/cjs/loader:1146
  throw err;
  ^

Error: Cannot find module 'D:\git\mathjax\components\src\a11y\assistive-mml\'D:\git\mathjax\components\bin\build''
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.12.0
    Command failed: node 'D:\git\mathjax\components\bin\build'
node:internal/modules/cjs/loader:1146
  throw err;
  ^

Error: Cannot find module 'D:\git\mathjax\components\src\a11y\assistive-mml\'D:\git\mathjax\components\bin\build''
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.12.0

Building \src\a11y\complexity
node:internal/modules/cjs/loader:1146
  throw err;
  ^

Error: Cannot find module 'D:\git\mathjax\components\src\a11y\complexity\'D:\git\mathjax\components\bin\build''
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.12.0
    Command failed: node 'D:\git\mathjax\components\bin\build'
node:internal/modules/cjs/loader:1146
  throw err;

...

weifu6 avatar Jul 01 '24 02:07 weifu6

I'm curious about why you are rebuilding the MathJax files; are you modifying the MathJax source code? If not, then mathjax-full comes with everything already compiled and the components made, so there is no need to do that yourself.

I see that you are running in a Windows shell. The build tools were designed for unix, and we haven't done any testing on Windows, so yeah, things go wrong there.

I've managed to get it to work on Windows by making the following changes:

  • In the package.json file:

    • remove the | grep --line-buffered 'Building\\|Webpacking\\|Copying\\|npx' from line 42.
  • In the components\bin\build file:

    • On line 81, change the \/ to \\ in the dir.replace() call.
    • On line 235, add .replace(/\\/g, '/') after the GLOBAL to get ${GLOBAL.replace(/\\/g, '/')}.
    • On line 236, add .replace(/\\/g, '/') after the VERSION to get ${VERSION.replace(/\\/g, '/')}.
    • On line 295, add .replace(/\\/g, '/') just before the final semicolon.
  • In the components\bin\makeAll file:

    • On lines 55, 56, and 57, change the first and last single quite (') to double quotes (") in all three lines.
  • In the components\bin\pack file:

    • On line 61, add , {shell: true} before the final );, making it
          const child = spawn('npx', ['webpack', '--json'], {shell: true});
      
  • In the components\src\output\chtml\webpack.config.json file:

    • Add the lineconst path = require('path'); at the top of the file.
    • Change line 16 (originally line 15 before the line added above to be
            resource.request = path.join(__dirname, 'nofont.js');
      
  • Make the same changes to components\src\output\svg\webpack.config.json.

That should allow you to perform the npm run -s make-components command, unless I have missed something that I changed. Let me know if you continue to have problems. There will be a lot of output without the grep command, but it should at least run.

dpvc avatar Jul 01 '24 21:07 dpvc

Thank you very much for your patience. It works fine now.

weifu6 avatar Jul 02 '24 02:07 weifu6