Cannot install node modules using npm

I installed nodejs and npm from haiku depot… But when I tried to install hexo using npm, it returned an error.
npm -g hexo-cli
returned the following error

 code ENOENT
npm ERR! syscall mkdir
npm ERR! path /boot/system/lib/node_modules/hexo-cli
npm ERR! errno -2147459069
npm ERR! enoent ENOENT: no such file or directory, mkdir '/boot/system/lib/node_modules/hexo-cli'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

I also cannot update npm for that matter.
What is the workaround if there is any?

1 Like

/boot/system/lib is read-only directory. You need to use writable directory for installing NPM modules, for example /boot/system/non-packaged/lib/node_modules/hexo-cli.

3 Likes

Thanks for your response, greatly appreciate.

Oh dear! That would mean uninstalling nodejs20 and recompiling nodejs from source.
I tried to designate folder within the system, say /boot/home/nodeprojects and then do:

npm init
npm install xxx

This process did create a writable node_module and package.json but it did not work. For example, I could not install vue_js or hexo that way. With vue_js, I came up against the problem of unrecognised os (this was also a problem with gradlew or gradle).

Haiku is getting more and more interesting, but a lot to learn every step of the way.

1 Like

npm install hexo-cli is enough to install into ~/home (node-modules are installed there) you can also specify a certain prefix with: ~> npm install --prefix /boot/home/config/non-packaged/ hexo-cli

Thanks Begasus.
This works to install hexo-cli but hexo itself does not work after that and has issues with regular expression. Not sure what it means.

No idea there :confused: