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

Unexpected token error #7

Closed
yask123 opened this issue May 2, 2016 · 7 comments
Closed

Unexpected token error #7

yask123 opened this issue May 2, 2016 · 7 comments

Comments

@yask123
Copy link

yask123 commented May 2, 2016

I got unexpected token error in fix-path code.

This is the content of fix-path:

'use strict';
module.exports = () => {
    const env = process.env;

    if (process.platform === 'darwin') {
        return env.SHELL || '/bin/bash';
    }

    if (process.platform === 'win32') {
        return env.COMSPEC || 'cmd.exe';
    }

    return env.SHELL || '/bin/sh';
}();

When I removed last () , it didn't give invalid syntax error.

What could be wrong?

I installed nodejs via brew
$ node --version v5.10.1

@silverwind
Copy link
Collaborator

silverwind commented May 2, 2016

Not sure how this is related to this module, but you can't invoke a function declaration, you need to wrap it to create an expression, e.g. (() => 1)().

sindresorhus added a commit to sindresorhus/default-shell that referenced this issue May 2, 2016
@sindresorhus
Copy link
Owner

@yask123 Fixed in sindresorhus/default-shell@d3e4413. Just reinstall this module.

@silverwind
Copy link
Collaborator

Ah, the issue was in another module 👍 I wonder how that slipped through CI.

@sindresorhus
Copy link
Owner

@silverwind Somehow that syntax worked fine in Node.js 4.

@silverwind
Copy link
Collaborator

@sindresorhus yeah, looks like a v8 bug. Must've been fixed in 6.0.0 or earlier.

@silverwind
Copy link
Collaborator

@yask123
Copy link
Author

yask123 commented May 2, 2016

That was quick! Thanks! 👍

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

3 participants