espocrm / ext-template

Template repository for EspoCRM extensions
Creative Commons Zero v1.0 Universal
31 stars 17 forks source link

When running node build --all It fails (Error: Command failed: npm ci.) #14

Closed rabiibrahimi closed 1 year ago

rabiibrahimi commented 1 year ago
Screenshot 2023-03-03 at 13 13 32

I can't run node build --all it always failed Error: Command failed: npm ci.

I am using macbook pro M1. any idea whyl npm ci fails.

node version: v19.6.1 npm version: 9.5.0

yurikuzn commented 1 year ago

Can you help to find out. I'm dealing with a few dozens issues daily, it's really hard for me.

yurikuzn commented 1 year ago

I tried on my environment and it worked w/o errors.

rabiibrahimi commented 1 year ago

It is weird i think this is an issue with silicon M1 chips, cause i can see that the script doesn't get passed npm ci (cp.execSync("npm ci", {cwd: './site', stdio: 'ignore'});) it stops here. i will keep looking to see if i can manage to fix this on my environment. Thanks

czcpf commented 1 year ago

@rabiibrahimi I have a similar issue. What is the fix here? node v20.0.0 npm v9.6.4 2023-04-19T19_45_58_125Z-debug-0.log

czcpf commented 1 year ago

I made some progress here.

from cp.execSync("npm ci", {cwd: './site', stdio: 'ignore'}); to cp.execSync("npm ci", {pwd: './site', stdio: 'ignore'});

This gets me past the npm stage but now i'm getting an error on the next line

cp.execSync("grunt", {cwd: './site', stdio: 'ignore'});

I tried cp.execSync("grunt", {pwd: './site', stdio: 'ignore'});

but that doesn't work. I see that Gruntfile.js in /site has a bunch of cwd references as well. Is this some issue on intel mac understanding cwd ?

UPDATE

It looks like this won't build at all with node v20. on my intel mac only node v16. seems to be working with this.

So here is how I got this to work for anyone who wants to save hours and hours...

brew remove node brew install node@16 brew link --overwrite node@16

rabiibrahimi commented 1 year ago

i have solved it by downgrade node and npm so currently i use these versions: node v16.19.1 npm 8.19.3

and it works now. guess it is issue with version compatibility.

czcpf commented 1 year ago

Well, I’m glad the solution is on the internet somewhere now to save someone else hours of wasted time. Maybe Yuri can update the Readme to advise only node v16.  npm 8. is compatible for building or update this to use a more recent version of node.  Homebrew actually installs node and npm together when installing node package. On Apr 20, 2023, at 8:32 AM, Rabii Brahimi @.***> wrote: i have solved it by downgrade node and npm so currently i use these versions: node v16.19.1 npm 8.19.3 and it works now. guess it is issue with version compatibility.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

bandtank commented 1 year ago

M1/M2 macs don't work with version 16, so there is no way to fix the issue because version 14 is incompatible. The issue with 16 is as follows:

npm ERR! npm ERR! The chromium binary is not available for arm64:

I have not found a solution yet.

rabiibrahimi commented 1 year ago

it does i am on M1 Pro and using node v16.19.1 and npm v8.19.3 and it works fine. just for your info i am using laravel valet for dev env.

bandtank commented 1 year ago

You must have not installed it recently or without needing to install the chromium binary. npm will not resolve the chromium dependency.

czcpf commented 1 year ago

I am using brew package manager. If you have any specific instructions on how to upgrade node and npm using brew so this works please advise.

From: Anthony Andriano @.> Date: Thursday, May 25, 2023 at 1:16 PM To: espocrm/ext-template @.> Cc: czcpf @.>, Comment @.> Subject: Re: [espocrm/ext-template] When running node build --all It fails (Error: Command failed: npm ci.) (Issue #14)

You must have not installed it recently or without needing to install the chromium binary. npm will not resolve the chromium dependency.

— Reply to this email directly, view it on GitHubhttps://github.com/espocrm/ext-template/issues/14#issuecomment-1563317217, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVBA57M7T3R6C34ILZ25QC3XH6OWBANCNFSM6AAAAAAVOTGVHA. You are receiving this because you commented.Message ID: @.***>

czcpf commented 1 year ago

I am usingnode v16.19.1npm 8.19.3And it works. It stops working when you go above that as far as I can tell. On May 25, 2023, at 2:06 PM, @.*** wrote:

@font-face { font-family: "Cambria Math"; } @font-face { font-family: Calibri; } p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; } a:link, span.MsoHyperlink { color: blue; text-decoration: underline; } span.EmailStyle19 { font-family: Calibri, sans-serif; color: windowtext; } .MsoChpDefault { font-size: 10pt; } @page WordSection1 { size: 8.5in 11in; margin: 1in; } div.WordSection1 { page: WordSection1; }

I am using brew package manager. If you have any specific instructions on how to upgrade node and npm using brew so this works please advise.  

From: Anthony Andriano @.> Date: Thursday, May 25, 2023 at 1:16 PM To: espocrm/ext-template @.> Cc: czcpf @.>, Comment @.> Subject: Re: [espocrm/ext-template] When running node build --all It fails (Error: Command failed: npm ci.) (Issue #14)

You must have not installed it recently or without needing to install the chromium binary. npm will not resolve the chromium dependency. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

rabiibrahimi commented 1 year ago

You must have not installed it recently or without needing to install the chromium binary. npm will not resolve the chromium dependency.

You are right, this was solved couple months for my Mac M1.

bandtank commented 1 year ago

I gave up trying to make this work in OSX with an M1 processor:

/site: node --version
v16.19.1
/site: npm --version
8.19.3
/site: npm ci
...
npm ERR! npm ERR! code 1
npm ERR! npm ERR! path /Users/test/.npm/_cacache/tmp/git-clone1o9YKE/node_modules/puppeteer
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c -- node install.js
npm ERR! npm ERR! The chromium binary is not available for arm64: 
npm ERR! npm ERR! If you are on Ubuntu, you can install with: 
npm ERR! npm ERR! 
npm ERR! npm ERR!  apt-get install chromium-browser
npm ERR! npm ERR! 
npm ERR! npm ERR! /Users/test/.npm/_cacache/tmp/git-clone1o9YKE/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:112
npm ERR! npm ERR!             throw new Error();
npm ERR! npm ERR!             ^
npm ERR! npm ERR! 
npm ERR! npm ERR! Error
npm ERR! npm ERR!     at /Users/test/.npm/_cacache/tmp/git-clone1o9YKE/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:112:19
npm ERR! npm ERR!     at FSReqCallback.oncomplete (node:fs:202:21)
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /Users/test/.npm/_logs/2023-05-28T11_23_52_741Z-debug-0.log

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/test/.npm/_logs/2023-05-28T11_23_49_887Z-debug-0.log

Nothing has worked. Now I'm trying in Docker. Using linux/arm64, which is the default platform for my system, didn't work due lack of arm64 support for PhantomJS. Switching to linux/amd64 pushed the process forward, but now grunt is missing.

# node build --all
Fetching EspoCRM repository...
  Downloading EspoCRM archive from Github...
  Unzipping...
Installing EspoCRM instance...
  Creating config...
  Npm install...
  Building...
node:internal/errors:857
  const err = new Error(message);
              ^

Error: Command failed: grunt
    at checkExecSyncError (node:child_process:861:11)
    at Object.execSync (node:child_process:932:15)
    at buildEspo (/app/build.js:188:8)
    at /app/build.js:124:9
    at new Promise (<anonymous>)
    at install (/app/build.js:118:12)
    at /app/build.js:16:17 {
  status: 127,
  signal: null,
  output: [ null, null, null ],
  pid: 361,
  stdout: null,
  stderr: null
}
# pwd
/app
# cd site
# grunt
/bin/sh: 5: grunt: not found

This site says to do the following: npm install -g grunt-cli and then npm install grunt-cli --save-dev in the project's root folder. Note: The repository's instructions do not say to install grunt-cli, but it is a required dependency.

Once that was resolved, the process fails again:

# node build --all
Fetching EspoCRM repository...
  Downloading EspoCRM archive from Github...
  Unzipping...
Installing EspoCRM instance...
  Creating config...
  Npm install...
  Building...
  Install: step1...
  Install: setupConfirmation...
  Install: checkPermission...
  Install: saveSettings...
  Install: buildDatabase...
  Install: createUser...
  Install: finish...
  Merge configs...
node:internal/errors:857
  const err = new Error(message);
              ^

Error: Command failed: php merge_configs.php
    at checkExecSyncError (node:child_process:861:11)
    at Object.execSync (node:child_process:932:15)
    at /app/build.js:175:12
    at new Promise (<anonymous>)
    at install (/app/build.js:118:12)
    at /app/build.js:16:17 {
  status: 255,
  signal: null,
  output: [ null, Buffer(0) [Uint8Array] [], Buffer(0) [Uint8Array] [] ],
  pid: 3472,
  stdout: Buffer(0) [Uint8Array] [],
  stderr: Buffer(0) [Uint8Array] []
}

Running the file directly shows the error:

# php php_scripts/merge_configs.php
PHP Warning:  include(../site/bootstrap.php): Failed to open stream: No such file or directory in /app/php_scripts/merge_configs.php on line 3
PHP Warning:  include(): Failed opening '../site/bootstrap.php' for inclusion (include_path='.:/usr/share/php') in /app/php_scripts/merge_configs.php on line 3
PHP Fatal error:  Uncaught Error: Class "Espo\Core\Application" not found in /app/php_scripts/merge_configs.php:5
Stack trace:
#0 {main}
  thrown in /app/php_scripts/merge_configs.php on line 5

I don't know what to do at this point.

rabiibrahimi commented 1 year ago

Once that was resolved, the process fails again:

I have had same and it was just database, before running node build --all MAKE SURE YOU HAVE CREATED A DATABASE IN MYSQL. of course database should match the name of db you set in config.json and also username and password.

bandtank commented 1 year ago

On an M1 mac, you have to do this:

export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

Once that has been done, it seems to work. Note: it is important to watch the log files in site/data/logs/. Node's output is useless once Espo has started running. For example, if a database isn't accessible, node fails without saying why, but Espo's log will at least mention sql errors.

Here is my setup:

M1 Max
Ventura 13.3.1(a)

node --version
v16.19.1

npm --version
8.19.3

composer --version
Composer version 2.5.6 2023-05-24 09:14:18

php --version
PHP 8.2.6 (cli) (built: May 10 2023 06:14:09) (NTS)