For some reason I can’t install NPM (maybe) i tried to verify the version but it gave me error [ i ran node , i typed npm -v and i got an error message saying reference error npm is not defined
Pok, Many thanks , got it to work , Very happy
@ST2 great to hear that you have it working. Sorry for the lack of reply unfortunately this is contract season for me and unfortunately my side projects usually are the first to go
@Pok thank you
- Ron
Thank you Ron, I really appreciate you sending this email to me and many
many thanks for all the fine and useful work you’ve done for this community
Best regards
Saad Thabit
Founder and Principal Engineer
DRF Engineering Services LLC.
860 Worcester Road| Suite 101
Framingham, MA.
01702508.314.0845thabit@drfengineeringservices.comwww.drfengineeringservices.com
https://www.facebook.com/DRF-Engineering-Services-1549921131971008/
https://www.linkedin.com/in/saad-thabit-481071a
Not sure you meant to send this message to the forum?
Hi All,
I’ve finished implement some new feature to the plugin and I was wondering if anyone fancy trying it out before the final merger for release?
Here’s what changed on 0.0.9 (peding release)
Added
- Added support for options files. for now on any new features will be implemented and made configurble via the options file. this will also make it eaiser to have a standard setup between projects.
- Added PDF support. the PDF generator uses html templates to create the PDF file.
- Added HTML_PDF template for use with the PDF generator
- Added BOM sort and the related configuarable settings. You can now sort ASC/DEC by ref, value and footprint.
Fixed
- Fixed the issue where file names with space would break class tags
- Fixed the missing filed header class tags
Here’s what the new PDF template looks like
and here the PDF example if anyone want to have a closer look.
kicad_bom_wizard PDF output hash Define electronics.pdf (138.3 KB)
Getting the dev code
To get access to 0.0.9 you will need to git clone the project and then checkout the develop branch.
git clone https://github.com/HashDefineElectronics/KiCad_BOM_Wizard.git
cd ./KiCad_BOM_Wizard
git checkout develop
then you will need to run the install
npm install -g ./
Using it
At this point, you should be able to use the plugin the same way as you did previously except that you can now pass it a config instead of a series of commands parameters.
you can find an example of the config file on the project root directory under Example/options.json.
Using the new config file, all you need to do is now call kicad_bom_wizard and give it the location of your config file.
kicad_bom_wizard CONFIG_PATH/options.json
where CONFIG_PATH is the directory to the options.json.
configuration file example
Here what the configuration file looks like. All path can be relative to the config file, relative your current working directory, relative to kicad_bom_wizard or absolute .
{
"version" : 2,
"outputType" : "pdf",
"templatePath" : "HTML_PDF",
"outputPath" : "../Test/.tmp/",
"outputName" : "output.pdf",
"input": "example.xml",
"pdfOptions": {
"pageSize": "A3",
"printBackground" : true,
"landscape": true,
"marginsType" : "0"
},
"sort" : {"by": "ref", "ascending": true}
}
-
outputType needs to be either pdf or file. where file is that you intent to make you own text file. for example csv or html.
-
templatePath this is the path to your template file. This can either be CSV, HTML, HTML_PDF or a path to your own.
-
outputPath this is where you intend to save your output file
-
outputName this the name that you want to the output file to be called.
-
input this the path and name of your project xml file.
-
pdfOptions this are some of the options for configuring the PDF output if you are using PDF
-
sort by this sets the BOM component grouped sort order. You can set it too ref, value, value_num and footprint. where value_num means that the value filed is to be treated as numbers.
– Ron
Hi ! I’m getting the following error when attempting to use the BOM Wizard:
Command error. Return code 8
Info messages:
KiCad_BOM_Wizard Rev: 0.0.8
Error messages:
module.js:340
throw err;
^
Error: Cannot find module ‘xml2js’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at ReadXmlFile (/home/grpace/Electronics/KiCad/BOM Wizard/KiCad_BOM_Wizard.js:433:16)
at Task (/home/grpace/Electronics/KiCad/BOM Wizard/KiCad_BOM_Wizard.js:608:7)
at Object. (/home/grpace/Electronics/KiCad/BOM Wizard/KiCad_BOM_Wizard.js:132:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
Running Ubuntu 14.04
Is a re-boot necessary after installing nodejs ?
Greg
Got this plugin “somewhat” working, and here’s my thoughts / findings:
Issues:
Having to install nodejs and npm just to get the BOM Wizard package to begin with.
Just wanted to test the plugin… Additional required installs/dependencies should NOT be necessary.
Once that’s installed, the BOM Wizard instructions state that from Eeschema, click the BOM button, then:
… click on the “Add Plugin” button. On the file explorer file, find and open “KiCad_BOM_Wizard.js”
It’s not stated that, under Linux, this location ends up being:
/usr/local/bin/kicad_bom_wizard
No… Wait… That’s just a symbolic link (symlink) pointing to somewhere else…
Now one has to look at the symlink’s properties to determine exactly where it points to. This ends up being:
/usr/local/lib/node_modules/kicad_bom_wizard/KiCad_BOM_Wizard.js
WHY is this plugin spread out like this ??
Then the BOM Wizard instructions further state:
… Its not ready, we still need to add the extra parameters to make it work… Under Command line: change it to the following…
node "SCRIPT_ROOT_DIR/KiCad_BOM_Wizard.js" "%I" "%O.html"
This ends up being (without the line-break shown here):
node "/usr/local/lib/node_modules/kicad_bom_wizard/KiCad_BOM_Wizard.js" "%I" "%O.html"
.
Nope… That fails with errors.
Have to remove the quotation marks around the path name to KiCad_BOM_Wizard.js
Nope… That fails with errors.
It’s not “node”… It’s “node.js”.
Correct that and… FINALLY ! GETTING SOME OUTPUT !
Now… Let’s try customizing the HTML template a bit…
It’s folder is located at:
/usr/local/lib/node_modules/kicad_bom_wizard/Template/HTML/
Guess what ??? THAT folder is owned by “root” !
Cannot customize it without forcing root privileges… NOT GOOD good on Linux systems.
So…
Open a terminal, navigate to that Template folder and use sudo
to change it’s owner to yourself so it can be edited.
Nope… Still can’t edit it… It’s also READ-ONLY !!
GREAT !! Now, what ??
You either have a choice of changing the templates from read-only where they sit, or loading them in a text editor and saving them to your home folder.
Reading the instructions further:
…change the Command Line: to the following.
node “SCRIPT_ROOT_DIR/KiCad_BOM_Wizard.js” “%I” “%O.MY_FILE_EXT” “YOUR_TEMPLATE”
YOUR_TEMPLATE is the directory path to your own template folder…
Well… That’s basically telling us we need template folders in two separate locations !! That really spreads this thing out even more !!
Then, once all that’s done, in order to use/place your own logo, you gotta visit
to get your logo image converted into a format suitable to place in the custom HTML’s style sheet section and save the template. Then, at least for me, the logo image fails to render.
Conclusion:
The installation of this plugin and getting it to somewhat work on Linux/Ubuntu is absolutely horrendous ! There is simply NO REASON it should be this way and one has to go through all these steps.
I truly hope the author addresses these issues before the next release.
Greg
Hi Greg, sorry to hear you were having issues with the setup process.
Hi ! I’m getting the following error when attempting to use the BOM Wizard:
Command error. Return code 8
Info messages:
KiCad_BOM_Wizard Rev: 0.0.8
Error messages:
module.js:340
throw err;
^
Error: Cannot find module ‘xml2js’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at ReadXmlFile (/home/grpace/Electronics/KiCad/BOM Wizard/KiCad_BOM_Wizard.js:433:16)
at Task (/home/grpace/Electronics/KiCad/BOM Wizard/KiCad_BOM_Wizard.js:608:7)
at Object. (/home/grpace/Electronics/KiCad/BOM Wizard/KiCad_BOM_Wizard.js:132:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
Running Ubuntu 14.04
Is a re-boot necessary after installing nodejs ?
Did you install it via npm or via git clone? If by git clone then you need to make sure that you run npm install -g --production kicad_bom_wizard
inside of the plugin directory. This will ensure that you have all the dependencies.
/usr/local/lib/node_modules/kicad_bom_wizard/KiCad_BOM_Wizard.js
WHY is this plugin spread out like this ??
For the issue that you had with the location and root permission for the plugin directory are all down to how NPM is setup. In linux, by default NPM is configure to use the root directories. This is something that NPM know is an issue to some of their user and have addressed by publishing this instruction on fixing it “03 - Fixing npm permissions”.
Nope… That fails with errors.
It’s not “node”… It’s “node.js”.
Correct that and… FINALLY ! GETTING SOME OUTPUT !
I’m guessing that you’ve installed nodejs via Ubuntu package (sudo apt-get install nodejs
). Unfortunately in ubuntu, the module node is taken up by another program and so when you install nodejs it has to to use nodejs.
This could be fixed if you manually download and install nodejs. This would also ensure that you have the latest version of nodejs and npm.
Now… Let’s try customizing the HTML template a bit…
It’s folder is located at:
/usr/local/lib/node_modules/kicad_bom_wizard/Template/HTML/
Even if you didn’t have the root permission issue here, I would still advice not to make changes to the templates that comes with the plugin. If you do then you are likely to loss your changes if you ever decide to up the plugin. Specially now that I’m in the process of introduction some new features. Ideally, you need to code the template and make your changes there.
to get your logo image converted into a format suitable to place in the custom HTML’s style sheet section and save the template. Then, at least for me, the logo image fails to render.
Would you be able to share your template so that I can see where it failed?
Conclusion:
The installation of this plugin and getting it to somewhat work on Linux/Ubuntu is absolutely horrendous ! There is simply NO REASON it should be this way and one has to go through all these steps.
I truly hope the author addresses these issues before the next release.
Unfortunately, some of the issues that you mentioned will be hard to remove without KiCad having better support nodejs. For example, Getting KiCad to recognise that you are running a nodejs script in the KiCad BOM tool rather than you have to manually insert node (or nodejs). That said, I’ve been playing with the idea of intergrating this plugin (or at least the functionality) into kicad. Its only something that I would do if the developer are happy for me to do it and enough people want it.
Not sure if you be interested but I’ve released 0.0.9 for testing. It has a new way to configure the pluiging and support for PDF creating. Hopefully it’ll remove some of issues that you’ve found.
I do wonder if it would be better if I add UI to the plugin so that it can run without having to worry user needing to use a terminal.
– Ron
Hi, Ron.
I’ll (maybe try) to better explain my thoughts.
I use grsync to backup my system. I have two profiles set up in it… One for the main operating system and another for only my /home
directory. This ‘separation of tasks’ makes backups much faster, as only what has changed since the initial or last backup gets updated. The way your plugin is structured (by needing external dependencies) breaks this separation.
I have looked at the npm link you posted, and will likely try Option 2 to see if that will help bring this ‘separation of tasks’ back in sync. I believe I’ve seen a post by you here that node/nodejs was the way you were most comfortable with developing software… There’s nothing wrong with that. However, it may be advantageous for new users of your plugin if you could better explain some of the caveats one could run in to and the available options for addressing them.
I installed it with npm. The thing is, I may never need or use nodejs and npm for anything else.
This was one of the major issues. Your documentation doesn’t define exactly where that plugin directory is… One has to hunt for it. Fortunately, Linux has the locate
command that helps some. As stated, a plugin for a particular software package shouldn’t have to need external dependencies to work. From an overall software design standpoint, I feel the packaging method of the plugin isn’t very eloquent.
That happening may very well be unlikely, as it appears most use Python for plugins and it is quite well supported. I somewhat doubt that nodejs support will be made widely available for only a few (but I could be wrong on that).
That would absolutely be an improvement. And as stated, updating your documentation to include pitfalls and viable work-arounds for a new user would help immensely… I was basically “going at it blind” while trying to get the plugin running.
I hope I have explained this well enough.
Have a good day !
Greg
I use grsync1 to backup my system. I have two profiles set up in it… One for the main operating system and another for only my /home directory. This ‘separation of tasks’ makes backups much faster, as only what has changed since the initial or last backup gets updated. The way your plugin is structured (by needing external dependencies) breaks this separation.
I understand. I have a similar need with my backup. You could always install the plugin without the -g command. This will ensure that the install is kept in the folder that you placed the plugin. The down side is that you won’t be able to access KiCad_BOM_Wizard globally because it won’t be added to your system path (its not like kicad can access it anyway :D)
For example:
cd ~/
git clone https://github.com/HashDefineElectronics/KiCad_BOM_Wizard.git
cd KiCad_BOM_Wizard/
npm install --production .
Here how to use it:
NODE_DIRECTORY/node ~/kicad_bom_wizard "%I" "%O.csv" "CSV"
I think I’ll add this to the use instruction just in case.
I have looked at the npm link you posted, and will likely try Option 2 to see if that will help bring this ‘separation of tasks’ back in sync. I believe I’ve seen a post by you here that node/nodejs was the way you were most comfortable with developing software… There’s nothing wrong with that. However, it may be advantageous for new users of your plugin if you could better explain some of the caveats one could run in to and the available options for addressing them.
I was hoping that this thread would help with that due to the limited time I have for side projects. That said, you are right and it makes since to add a dedicated section for common issues users might find.
This was one of the major issues. Your documentation doesn’t define exactly where that plugin directory is… One has to hunt for it. Fortunately, Linux has the locate command that helps some. As stated, a plugin for a particular software package shouldn’t have to need external dependencies to work. From an overall software design standpoint, I feel the packaging method of the plugin isn’t very eloquent.
Fair enough ;D
That happening may very well be unlikely, as it appears most use Python for plugins and it is quite well supported. I somewhat doubt that nodejs support will be made widely available for only a few (but I could be wrong on that).
Sadly you might be right. That said, I’ve been wondering if its worth porting the code over to python for this very reason but then again I’m not sure if the efforts would be worth it. it might be easier and possibly quicker if I simply added the necessary changes to KiCad and send a patch over to the Devs
– Ron
So I’m have trouble with mine. I’m using windows 10 and KiCad 4.0.4. I’ve installed nodejs via the windows installer and KiCad BOM Wizard.
When I generate the code using node “C:\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js” “%I” “%O.html” I get this error:
Run command:
node “C:/KiCad_BOM_Wizard-master/KiCad_BOM_Wizard.js” “C:/Users/User/Documents/1UInergy/KiCad/prototype2/prototype2.xml” “C:/Users/User/Documents/1UInergy/KiCad/prototype2/prototype2.html”
Command error. Return code 1
Info messages:
KiCad_BOM_Wizard Rev: 0.0.8
Error messages:
module.js:471
throw err;
^
Error: Cannot find module ‘xml2js’
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at ReadXmlFile (C:\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:432:16)
at Task (C:\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:607:7)
at Object. (C:\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:131:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)
This error looks similar to a few other users here. I tried putting the full path for node in but that doesn’t work. The windows installer put it in C:/ProgramData/Microsoft/Windows/Start Menu/Programs/Node.js so that’s what I put. With and without the .js
What do I try next?
Thanks!
Try using nodejs instead of node.
Remove any quotation marks around the node command.
Only use quotation marks around %I and %O variables.
See my post above… I tried to cover issues I had.
Greg
Still nothing. I think my full path from before wasn’t right. Nodejs is in C:/Program Files/Nodejs.
Since I used the windows installer, I shouldn’t have to run anything in the command prompt for nodejs, correct?
Got it working now except for the page settings -date, revision, title, company, etc don’t show up on either the html or csv.
Ended up entering: npm install -g --production kicad_bom_wizard from within the node.js command prompt and saw that the path it used was different from where I had extracted the KiCad_BOM_Wizard. I recalled Pok, earlier in this thread, had the same file path. That’s what I used.
Still don’t understand it, but it works well enough I guess.
Thanks for the help!
Hi Ryan,
After extracting KiCad_BOM_Wizard-master.zip did you run the npm install inside C:/KiCad_BOM_Wizard-master?
Also, I’ve just noticed a mistake I made on the instruction for installation KiCad_BOM_Wizard via git hub download
The instruction should have been:
unzip KiCad_BOM_Wizard-master.zip
cd KiCad_BOM_Wizard-master
npm install -g --production kicad_bom_wizard
where it actually said.
unzip KiCad_BOM_Wizard-master.zip -d KiCad_BOM_Wizard-master
This parameter -d KiCad_BOM_Wizard-master had the side effect of unzipping the project inside a subdirectory with the same name as the parent directory.
C:/KiCad_BOM_Wizard-master/ KiCad_BOM_Wizard-master /KiCad_BOM_Wizard.js
- Ron
So far I have been unsuccessful in using the plugin and would like to upload my npm-debug.log. Is there some way to do this as a new member?
Use any cloudservice of your choice and add the last link as text. Or read a few topics until you reach trust level basic.
Hiya, I’ve just replied to your email
If you want you can sent it to that email address and I’ll post here for you.
Which OS are you using?
When I tried to use KiCad_BOM_Wizard I got as far as the success message but there were still an error telling me to install npm in the Wizard directory. This surprised me because is was already installed and responds to commands. When I attempted an installation I got a lot of errors. Here is the npm-debug.log.