npm run sandbox not starting server
Closed this issue · 17 comments
Trying to follow the last step in this sample.
After running npm run sandbox
it stops with an error on the console:
Done.
Start test Server
Spawning sandbox at http://localhost:8084
Error with the sandbox... Don't forget to `npm install` first!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! IA-Core@2.2.1 sandbox: `grunt && node ./bin/start_sandbox.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the IA-Core@2.2.1 sandbox script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Versions I'm using
node v8.11.3
npm v6.1.0
IA-Core@2.2.1
Any ideas?
The error message is suggesting that you are missing some node modules. Did you run npm install
before trying to run the sandbox?
Yes I did. I got some warnings but nothing that alerts me that something is wrong:
$ npm install
npm WARN grunt-contrib-clean@0.6.0 requires a peer of grunt@~0.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN IA-Core@2.2.1 No repository field.
npm WARN IA-Core@2.2.1 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
audited 5799 packages in 23.088s
found 57 vulnerabilities (23 low, 22 moderate, 12 high)
run `npm audit fix` to fix them, or `npm audit` for details
I also ran npm audit fix
already, same result.
It's a shame we don't have more detailed errors. This is something we'll have to fix.
In the meantime, could you edit bin/start_sandbox.js
and replace lines 34-37
with these:
sandBox.stderr.on('data', (data) => {
console.log(error('Error with the sandbox... Don\'t forget to `npm install` first!'));
console.log(error('Error: ', data));
process.exit(1);
});
Run it again, this will give you a more detailed error, and I will hopefully be able to help you out!
Sure, thanks for the snippet. Here's the new log output after adding that:
Error:
D:\wampserver\www\qwant-ia\local_modules\ia-sandbox\app.js:46
throw `modules not found at ${MODULE_PATH}`
^
modules not found at src/modules/
btw. I do appreciate your prompt support - and that on a Sunday 👍
Thank you! Happy to help!
Oh, I just saw you're running Node 8.11.x. That's probably what is causing this!
This project currently needs Node 6.11.x to run properly. You need to install this version! The quickest way is using nvm.
Try this and if that doesn't solve it, I might have an idea to get an even more detailed error log.
I'm on Windows so I had to use nvm-windows which seems to work in switching versions. The error stays exactly the same though.
$ npm --version
6.1.0
$ node --version
v6.11.0
Odd!
Can you replace line 46
of this file /local_modules/ia-sandbox/app.js
with this line:
throw `error: ${e}`
Then, remove the installed module (rm -rf node_modules/@qwant/ia-sandbox
) and run npm install
. It will install it back with the modified code.
We will then have an error to work from. I'm thinking this might be a rights issue, but not sure! :)
Ok, now we got:
Error:
D:\wampserver\www\qwant-ia\local_modules\ia-sandbox\app.js:47
throw `error: ${e}`
^
error: Error: ENOENT: no such file or directory, scandir 'D:\wampserver\www\src\modules'
Looks to me as if it tries to look in a folder too high up in the tree for src\modules?
This really looks like an issue we had in Node 8.x...
Can you rm -rf node_modules
and make a clean npm install
, a clean grunt
and try and run the sandbox again?
ok, that somehow destroyed everything, I have to check out fresh and try from scratch tomorrow
I checked it out and ran everything with node 6.11.0 right from the start. I made the change to app.js "throw error: ${e}
" which does not seem to get thrown now but npm run sandbox
still does not work and I get:
Error with the sandbox... Don't forget to `npm install` first!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! IA-Core@2.2.1 sandbox: `grunt && node ./bin/start_sandbox.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the IA-Core@2.2.1 sandbox script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Any other ideas? Or what is the timeline on the node 8 version?
This is very weird, although now that I think about it I've had a similar problem on Windows after switching node versions, npm somehow relied on a cache that was built with the previous version. I would suggest removing/emptying this folder: C:\Users\xxxx\AppData\Roaming\npm-cache
, removing node_modules
and package-lock.json
(which may not exist, but may also have been created by Node 8/npm 6) in your IA project, and running npm install
again!
Did all that but end up with the exact same error.
Is there anything else I can try or should I wait for your Node 8 update?
Sorry for getting back to you so late! I must say I'm out of ideas. We haven't been able to reproduce that in any of our environments. It seems like the Node 8 install is still messing things up somehow...
After running npm install, do you have a package-lock.json
file in your root directory?
I don't have a package-lock.json
with Node 6 but had one with Node 8. I completely started from scratch after turning on Node 6 so no package-lock.json
was there.
I could try it on a different computer but to be honest this switching back to Node 6 seems to be not a great idea for development for all my other projects that are based on Node 8. If your update to Node 8 is not years away I'm inclined to wait. Is there a timeline on this?
Hey @ddsky ! Just a quick update to let you know that we released Instant Answers 4.0.0. It bundles a docker system, so you shouldn't have this issue anymore as the working environment is already set up.
Feel free to try again and tell us if you face any issue! Don't forget to read the doc as some things changed drastically. Enjoy!