yessky/hotrun

Getting Unable to resolve "true": unknown node or service

shahidcodes opened this issue · 13 comments

  1. I am using strapi.io@1.x server.
  2. I installed hotrun globally
  3. Happens only when i pass any argument such as -i or -w or -b hotrun server.js -i -b -w api
  4. hotrun server.js seems working fine but does not do any hmr
  1. -i option require a value, it's a port for node debugging
  2. -w options also requires a value, it's a file/dir for watching to hmr
  3. -b generally used with -i, it 's for node debugging and insert break points into your code;
  4. hotrun server.js does not do hmr, as no files to watch changes. in this case, you can create a hotrun.json in your project root, see my example in example/hotrun.json

see README.md

-i, --inspect [port]             Enable inspect mode on port
-b, --inspect-brk                Enable inspect break mode
-c, --config                     Specify a json config file
-e, --extensions [extensions]    List of extensions to hook into [.es6,.js,.es,.jsx]
-w, --watch [dir]                Watch directory "dir" or files, to hot compile
-f, --force [dir]                Force restart if directory "dir" or files changed
-x, --exclude [dir]              Exclude matching directory/files from watcher
-p, --use-polling                In some filesystems watch events may not work correcly. This option enables "polling" which should mitigate this type of issues
-V, --version                    output the version number
-h, --help                       output usage information

if your problem was resovled, plz close the issue.

Thanks. It worked. Although it didn't work with Strapi server but it worked it my other express server. It maybe because strapi uses mounted type of procedure. So even though module cache is wiped something remains which doesn't require the module again. Any suggestions?

it seems strapi also exported as global command line, if that case both hotrun and Strapi play as a node app runner

maybe show me your code piece, we can go ahead

tested with your sampe app, works fine.

"scripts": {
    "start": "hotrun -w api -f server.js server.js"
  }

s1

@shahidcodes does it work ?

Sorry @yessky for being late. I tested it seem working when I do something outside of exported controller object. Also I see this error
tools
when I remove that it works. Thats minor issue I can fix that. But I could'nt make it work with any of the controllers or services.
Steps to reproduce:-

  1. In any service like email.js#L10 add something.
  2. Call this service from a controller like this Email.js#L9

Or try this ( as this is usually what i do )

  1. In api/emails/config/routes.json add this object
"GET /email/test" : {
  "controller": "Email",
  "action": "test",
  "policies": []
},
  1. in api/emails/controllers/Email.js export this handler as test
test: function * () {
  this.body = {num:1}
}
  1. Restart the server to let strapi pick up the endpoint.
  2. Then open localhost:1337/email/test
  3. Change the num value and see if it reflects in the response
    ( it didnt work in my case)

I will fix it recently

Great looking forward to try out the fix.

Try the fix plz

It did'nt work.
Here is what I did.
I created an endpoint /hot and a controller hot ( which is a generator function ) in exported object.

  1. I returned an object { a: 2 } changing it didn't reflect in response.
  2. I created a variable outside of module.exports and returned it in response. Changing that variable also did not work.
  3. I created a module and exported a number from that module and I returned that module as response for /hot. This also did not work.

Now generator function is supported. please try the new version.

I'm considering to refactor, as current solution does not support change module export type, eg:

a.js
module.exports = 'string';

a.js updated
module.exports = function() {
  console.log('string to function')
};