mosjs / mos

:pill: A pluggable module that injects content into your markdown files via hidden JavaScript snippets
108 stars 8 forks source link

Error: spawn npm ENOENT #94

Open TitaneBoy opened 7 years ago

TitaneBoy commented 7 years ago

Hi.. I'm trying to use your modules but got the error described in the title. I've installed mos globally with npm and in my project, I've tried to use mos --init. I got the following error:

Error: spawn npm ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:189:19)
    at onErrorNT (internal/child_process.js:366:16)
    at _combinedTickCallback (internal/process/next_tick.js:102:11)
    at process._tickCallback (internal/process/next_tick.js:161:9)
    at Function.Module.runMain (module.js:607:11)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

I've installed locally the mos-plugin-package-json package to be able to print packages and their version in the md file but when executing the mos command, I got another error:

Error: Failed to register mos-plugin-shields. Error: The shields plugin only works for github repos
    at wrapError (C:\Users\MyUser\AppData\Roaming\npm\node_modules\mos\node_modules\remi\dist\index.js:38:24)
    at C:\Users\iMyUser\AppData\Roaming\npm\node_modules\mos\node_modules\remi\dist\index.js:46:26
    at <anonymous>

For the package-json package, in my markdown file, I've put the following inside the file:

< !--@'# ' + pkg.name-->

my-awesome-module

< !--/@-->

But as I said, I had the "Failed to register mos-plugin-shileds" error.

Can you help me please ?

Thank you

zkochan commented 7 years ago

hi, I'll fix the shields issue in a few minutes

zkochan commented 7 years ago

you have to have mos installed in your project as a dev dep. If so, update it, I published a fix to mos-plugin-shields. Use npm update --depth 100

TitaneBoy commented 7 years ago

Hi @zkochan . Thanks a lot for your quick answer..

I'm not sure but I think that your fix is not yet publish to npm..The last release of mos in npm is about a year ago.. Am I wrong ?

zkochan commented 7 years ago

it is a subdeps of mos that was fixed. A deep update will load the new, fixed package

TitaneBoy commented 7 years ago

Well...I've uninstalled and installed again mos in my project...I guess that should get the last version of "mos"... I'm not sure but I think that uninstalling and installing again the module is kind of.."deep update", right ? Or may be I'm missing something..?

zkochan commented 7 years ago

ok, so the error is not gone?

TitaneBoy commented 7 years ago

The last version of mos, after installing it, is 1.3.1 and is dated to 2016-06-14.. So, I don't think that the last version of mos, with the fix, is yet published in npm..

With the version 1.3.1 of mos, when installed locally, with templating syntax in readme.md (as described in my first post), and when executing the "mos" command, I got this error:

C:\Test\Express\MyApp>node_modules\.bin\mos
Error: Failed to register mos-plugin-shields. Error: The shields plugin only works for github repos
    at wrapError (C:\Test\Express\MyApp\node_modules\remi\dist\index.js:38:24)
    at C:\Test\Express\MyApp\node_modules\remi\dist\index.js:46:26
    at <anonymous>
TitaneBoy commented 7 years ago

Note: I've installed locally "mos" and "mos-plugin-package-json"

zkochan commented 7 years ago

The error was in mos-plugin-shields which is a dependency of mos. There is no need to publish a new version of mos. I published mos-plugin-shields@2.2.3 with the fix. When reinstalling mos, it will have the fixed dependency

TitaneBoy commented 7 years ago

Well...I'm sorry...My bad...You're right... The first error described in this issue is gone... But as I said, when I'm executing "mos" in the root directory, I have the "Failed to register mos-plugin-shields. Error: The shields plugin only works for github repos" error as described earlier... Can you tell me please what I'm doing wrong or what I am missing ?

zkochan commented 7 years ago

But that's the error I was trying to fix

Could you run npm list mos-plugin-shields --depth 10 to check what version of mos-plugin-shields you have installed?

TitaneBoy commented 7 years ago

Sure...This is what I got:

C:\Test\Express\MyApp>npm list mos-plugin-shields --depth 10
myproject@1.0.19 C:\Test\Express\MyApp
`-- mos@1.3.1
  `-- mos-plugin-shields@2.2.0
zkochan commented 7 years ago

So weird, the latest version of mos-plugin-shields is 2.2.3, so that one should have been installed. Do you have a package-lock.json or yarn.lock? Maybe they locked the version of mos-plugin-shields

TitaneBoy commented 7 years ago

Well..I'm using yarn and What I decided to do, is to remove completely node_modules and yarn.lock. So I've installed again my modules...but there is no way to upgrade with yarn the mos-plugin-shields related to mos... Because when I'm doing the following command

yarn upgrade mos-plugin-shields, it will add a new mos-plugin-shields module but the mos module will continue to use the old one (2.2.0) instead of the 2.2.3. There is no --depth option available for upgrading modules with yarn (yarn upgrade). So I guess that the best way should to update the package.json of the mos project to put the new version of the mos-plugin-shields module

TitaneBoy commented 7 years ago

For now, I've decided to cheat a little bit and I've replaced manually the mos-plugin-shields folder in node_nodules so mos could use the new version of it.

It looks there is no error.. But I see other issue..

For example, in my readme.md file, I had stuff writted in the ## Installation section but after the "mos" command, it disappears completely.

And the last, I put the following in my readme.md file:

< !--@'# ' + pkg.name-->

. my-awesome-module

< !--/@-->

(Note: I put a dot (.) near the "#" so it could be seen in github. Same for the space after the "<")

After the mos command, there is no packages and versions in the readme.md file. The my-awesome-module is replaced with the name of my project (set in package.json) and that's all. Do you know what I'm doing wrong ?

TitaneBoy commented 7 years ago

Thank you in advance for your help and answer

zkochan commented 7 years ago

of course, sorry this package is a bit unmaintained because I spend all my time on pnpm.

Maybe try to write the header as in the usage example: https://github.com/mosjs/mos#usage

I don't know why the ## Installation section disappeared, does appear again on next generation? It should be generated automatically from info that is in package.json

TitaneBoy commented 7 years ago

I forgot to mention that For the ## Installation section, My stuff disappears but is replaced with:

```sh npm install --save my_project_name ``` Where my_project_name is the name of the project defined in package.json. On each generation, still have the same thing as described above

I've put the header as in the usage example but had the same behavior: It will only write between the two <!-- the name of the projected defined in package.json

mos issue

zkochan commented 7 years ago

all seems correct. h1([pkg.name]) adds the # project_name. If you want the project version there, you have to write something like h1([pkg.name + '@' + pkg.version]).

The installation section is automatically replaced as of mos v1. You can install mos@next if you don't want that.

TitaneBoy commented 7 years ago

Thank you...but what I must do to have package version...I mean...dependencies and their versions, in the markdown file ?

TitaneBoy commented 7 years ago

I just don't understand/know the syntax to use for that...

zkochan commented 7 years ago

oh, I guess you need this

TitaneBoy commented 7 years ago

Well..thanks for the info...And how to get versions value of these dependencies ?

zkochan commented 7 years ago

It will create sections like this. It only prints the names of packages, no versions.

If you really need versions there, you can update mos-plugin-dependencies with an option that will make it print names + versions. Or you can fork it and create your custom plugin

k-soze commented 5 years ago

Hello @zkochan, can you please change the dependencies versions in mos/package.json so that it takes the last versions of plugins (not a static one) like using ^. Thanks And thank you for this awesome project :)