Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cases failing #111

Closed
geoHeil opened this issue Jul 1, 2016 · 11 comments
Closed

Test cases failing #111

geoHeil opened this issue Jul 1, 2016 · 11 comments

Comments

@geoHeil
Copy link

geoHeil commented Jul 1, 2016

Hi npm test works fine on osx, but on Ubuntu it is failing with the following error:

Requiring external module ts-node/register
TSError: ⨯ Unable to compile TypeScript
test/gulpfile.ts (1,22): Cannot find module 'path'. (2307)
test/gulpfile.ts (4,9): Cannot find name 'require'. (2304)
test/gulpfile.ts (12,9): Cannot find name 'require'. (2304)
test/gulpfile.ts (13,16): Cannot find name 'require'. (2304)
test/gulpfile.ts (14,18): Cannot find name 'require'. (2304)
test/gulpfile.ts (14,31): Cannot find name 'process'. (2304)
test/gulpfile.ts (30,25): Cannot find name 'require'. (2304)
test/gulpfile.ts (46,18): Cannot find name 'require'. (2304)
test/gulpfile.ts (57,20): Cannot find name 'require'. (2304)
test/gulpfile.ts (59,22): Cannot find name 'process'. (2304)
test/gulpfile.ts (69,20): Cannot find name 'require'. (2304)
test/gulpfile.ts (71,22): Cannot find name 'process'. (2304)
test/gulpfile.ts (82,21): Cannot find name 'require'. (2304)
    at getOutput (/clicker/node_modules/ts-node/src/index.ts:280:15)
    at compile (/clicker/node_modules/ts-node/src/index.ts:289:14)
    at loader (/clicker/node_modules/ts-node/src/index.ts:304:23)
    at Object.require.extensions.(anonymous function) [as .ts] (/clicker/node_modules/ts-node/src/index.ts:321:14)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Liftoff.handleArguments (/clicker/node_modules/gulp/bin/gulp.js:116:3)
    at Liftoff.<anonymous> (/clicker/node_modules/gulp/node_modules/liftoff/index.js:193:16)

Here is a dockerfile https://gist.github.com/geoHeil/48cd94bf4d748fd8fd6d25de4c272157 which demonstrates a linux environment which leads to this error.

@lathonez
Copy link
Owner

lathonez commented Jul 2, 2016

@geoHeil our CI builds are on Ubuntu 14.04 and I run arch, so it's unlikely to be a linux or ubuntu specific issue.

The above error is the typescript compiler not being able to find the node typiings:

x220:~/code/clicker$ grep node typings.json 
    "node": "registry:dt/node#6.0.0+20160514165920",

I'll have a look with the docker file you've provided later on

@lathonez
Copy link
Owner

lathonez commented Jul 2, 2016

replicated using the dockerfile provided

@lathonez
Copy link
Owner

lathonez commented Jul 2, 2016

I just had to run typings install as a separate step, so for some reason the post install hook is failing in your setup:

    "postinstall": "ionic state restore && typings install && webdriver-manager update && cp test/karma-static/*.html node_modules/karma/static",

@lathonez
Copy link
Owner

lathonez commented Jul 2, 2016

npm WARN cannot run in wd [email protected] ionic state restore && typings install && webdriver-manager update && cp test/karma-static/*.html node_modules/karma/static (wd=/clicker)

@lathonez
Copy link
Owner

lathonez commented Jul 2, 2016

Possibly relevant:

http://stackoverflow.com/questions/18136746/npm-install-failed-with-cannot-run-in-wd

If npm was invoked with root privileges, then it will change the uid to the user account or uid specified by the user config, which defaults to nobody. Set the unsafe-perm flag to run scripts with root privileges.

Which would make sense as I presume you're running as root (I am when I replicate, and there doesn't seem to be another user on your image)

@lathonez
Copy link
Owner

lathonez commented Jul 2, 2016

npm install --unsafe-perms

did not work

@geoHeil
Copy link
Author

geoHeil commented Jul 2, 2016

Thanks a lot.

@lathonez
Copy link
Owner

lathonez commented Jul 2, 2016

Adding --allow-root-install to the postinstall line does the trick:
EDIT: --allow-root-install doesn't actually work

The way forward seems to be just running npm run postinstall after npm install

I'm not keen to put this in the repo as default as I'm not clear on the consequences of doing so. I don't think it's good practice to run anything as root (even in docker).

I will however put something in the readme and link this issue from the blog.

@geoHeil
Copy link
Author

geoHeil commented Jul 2, 2016

Nope you are right. I will change the docker file.

@lathonez
Copy link
Owner

lathonez commented Jul 2, 2016

Sweet, closing

@lathonez lathonez closed this as completed Jul 2, 2016
@lathonez
Copy link
Owner

#191

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants