How to update pdfmake?

Hi @hillel and Co!
Is there any way to update pdfmake in Invoiceninja v4?
I see that the current embedded version is 0.1.36 ( ./resources/assets/js/pdfmake.js) but the newest available stable version is 0.1.69. This is mainly to enable SVG which was added to pdfmake in version 0.1.59.
Could you outline the procedure how you built pdfmake from source and which files need to be replaced please?

Hi,

Sorry, we don’t plan to update pdfmake in v4.

If you’d like to try updating it yourself there’s a bit of info here:

https://docs.invoiceninja.com/developer_guide.html#code

Yes I understand and I am trying to update it myself.
But I need some additional info such as how was pdfmake built? Is it a single file to replace?
I saw the hint in the documentation:

you can download the source files with Bower. After making any changes you need to run gulp to re-generate the built files.

But can you add some additional information where exactly this needs to be run (in the root app path?) and if bower will also download the newest version of pdfmake or does the version need to be defined somewhere?

thx

Sorry we provide app support but aren’t able to provide developer support, that said…

Yes, it needs to be run in the root path. It looks like the bower version is defined here:

1 Like

Thanks so far, appreciate your answer. I was able to download the newest version with bower but it seems that following the documentation

After making any changes you need to run gulp to re-generate the built files.

is not enough. Does gulp need to be invoked with a special config? Do I have to run npm install first as it is mentioned in the error output?

ckadm@mintp ~/build/invoiceninja-4.5.29 $ gulp -f gulpfile.js 
[11:31:42] Local modules not found in ~/build/invoiceninja-4.5.29
[11:31:42] Try running: npm install

I have the feeling that this is the last step before success :grin:
I’m not a node developer so this might be something straightforward to devs, but not to me.
Also not sure which node version is supported or what the minimum required version is. Seems to fail with node v4.2.6 (from Ubuntu packages).

I’m not sure, have you tried running npm install? You will also need to install the bower dependancies.

I ran the following order:

bower update
npm install
gulp -f gulpfile.js

But npm install gives me already an error:

19465 error Linux 4.15.0-126-generic
19466 error argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
19467 error node v4.2.6
19468 error npm  v3.5.2
19469 error code EMISSINGARG
19470 error typeerror Error: Missing required argument #1
19470 error typeerror     at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
19470 error typeerror     at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
19470 error typeerror     at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
19470 error typeerror     at /usr/share/npm/lib/install/deps.js:457:7
19470 error typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
19470 error typeerror     at /usr/share/npm/lib/fetch-package-metadata.js:37:12
19470 error typeerror     at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
19470 error typeerror     at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
19470 error typeerror     at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
19470 error typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
19471 error typeerror This is an error with npm itself. Please report this error at:
19471 error typeerror     <http://github.com/npm/npm/issues>
19472 verbose exit [ 1, true ]

It’s possible that this is because another node or npm version is required.

I think you’d want to run bower install not update

OK thanks. Tried that but still fails to build.

bower install itself seemed to work, no error. But then again, gulp shows the same error as above. npm install (whether or not needed?) doesn’t work either.

The error says “This is an error with npm itself”, maybe it’s a problem with the specific version of node or npm?

Yes, that’s what I suspect, too.
Can you give hint which versions you are using when you build the packages, please?

I can check on Sunday

1 Like

Looks better with node v14.15.4 and npm 6.14.11. However now getting a missing laravel module:

$ gulp -f gulpfile.js 
Error: Cannot find module 'laravel-elixir'
Require stack:
- /home/ckadm/invoiceninja-4.5.29/gulpfile.js
- /usr/local/lib/node_modules/gulp/node_modules/gulp-cli/lib/shared/require-or-import.js
- /usr/local/lib/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^3.7.0/index.js
- /usr/local/lib/node_modules/gulp/node_modules/gulp-cli/index.js
- /usr/local/lib/node_modules/gulp/bin/gulp.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/ckadm/invoiceninja-4.5.29/gulpfile.js:1:14)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/ckadm/invoiceninja-4.5.29/gulpfile.js',
    '/usr/local/lib/node_modules/gulp/node_modules/gulp-cli/lib/shared/require-or-import.js',
    '/usr/local/lib/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^3.7.0/index.js',
    '/usr/local/lib/node_modules/gulp/node_modules/gulp-cli/index.js',
    '/usr/local/lib/node_modules/gulp/bin/gulp.js'
  ]
}

Assuming this is another npm module. Can you confirm?

Sorry, I’m not sure. It’s possible the code is broken, it hasn’t been run in a long time. It isn’t needed for most releases.

Have you considered upgrading to v5? The invoice designs now use HTML/CSS which makes it far easier to work with.

Yes, a migration to v5 will definitely happen. But there are multiple workflows involved which are all based on the V4 API. If this workflow works 100% after a migration to V5 needs a lot of testing first.
That’s why I wanted to “simply replace” the pdfmake.js with a newer version. :wink:
Turns out it’s not that simple though.