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

Syntax error when running with sudo #2266

Closed
gustavooliveiraf opened this issue Jan 6, 2020 · 6 comments
Closed

Syntax error when running with sudo #2266

gustavooliveiraf opened this issue Jan 6, 2020 · 6 comments
Assignees
Labels
support Questions, discussions, and general support

Comments

@gustavooliveiraf
Copy link

Support plan

  • is this issue currently blocking your project? (yes/no): yes
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: 12.14.0
  • module version with issue: 17.0.0
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): hapi

What are you trying to achieve or the steps to reproduce?

sudo node app.js

What was the result you got?

.../node_modules/@hapi/joi/lib/errors.js:246
    isJoi = true;
            ^

SyntaxError: Unexpected token =

What result did you expect?

run successfully

@gustavooliveiraf gustavooliveiraf added the support Questions, discussions, and general support label Jan 6, 2020
@Marsup Marsup self-assigned this Jan 6, 2020
@Marsup
Copy link
Collaborator

Marsup commented Jan 6, 2020

I'm going to guess your node version is not what you expect with sudo because you're using nvm or something alike. If you want to preserve the node version you need to use sudo -E.

@Marsup Marsup closed this as completed Jan 6, 2020
@Rapol
Copy link

Rapol commented Jan 7, 2020

Context
node version: 10.14.1
module version with issue: 17.0.0
environment (e.g. node, browser, native): node
used with (e.g. hapi application, another framework, standalone, ...): standalone

Im running into the same problem with or without sudo. I was able to reproduce it outside our project by just creating a file that just imports joi 17.0.0. I downgraded to 16.1.0 and it works

test/node_modules/@hapi/joi/lib/errors.js:246
    isJoi = true;
          ^

SyntaxError: Unexpected token =
    at new Script (vm.js:79:7)
    at createScript (vm.js:251:10)
    at Object.runInThisContext (vm.js:303:10)
    at Module._compile (internal/modules/cjs/loader.js:656:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)

@Marsup
Copy link
Collaborator

Marsup commented Jan 7, 2020

Joi 17 release notes explicitly specified that it's only compatible with node 12+, so as expected.

@Rapol
Copy link

Rapol commented Jan 7, 2020

Ah, sorry about that. Tried to find the release notes before commenting but couldn't find them. Would it be possible to add the compatible node versions in the package.json?

@Marsup
Copy link
Collaborator

Marsup commented Jan 7, 2020

Unlikely, we had too many problems with either npm or yarn when doing that.

@Marsup
Copy link
Collaborator

Marsup commented Jan 7, 2020

And I forgot, but you do have that information here: https://hapi.dev/family/joi/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

3 participants