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

error Parsing error: The keyword 'import' is reserved #84

Closed
AliveDD opened this issue Mar 25, 2016 · 41 comments
Closed

error Parsing error: The keyword 'import' is reserved #84

AliveDD opened this issue Mar 25, 2016 · 41 comments
Labels

Comments

@AliveDD
Copy link

AliveDD commented Mar 25, 2016

i cant intall this
i run in my terminal 3 commands:
Clone the project. git clone https://github.com/coryhouse/react-slingshot.git.
Install Node packages. npm install
Run the example app. npm start -s

and terminal return this messages

/Users/eugene/Documents/git/cit-one/webpack.config.js
4:1 error Parsing error: The keyword 'import' is reserved
/Users/eugene/Documents/git/cit-one/tools/build.js
4:1 error Parsing error: The keyword 'import' is reserved
/Users/eugene/Documents/git/cit-one/tools/buildHtml.js
10:1 error Parsing error: The keyword 'import' is reserved
/Users/eugene/Documents/git/cit-one/tools/distServer.js
4:1 error Parsing error: The keyword 'import' is reserved
/Users/eugene/Documents/git/cit-one/tools/srcServer.js
5:1 error Parsing error: The keyword 'import' is reserved
✖ 5 problems (5 errors, 0 warnings
ERROR: lint:tools: None-Zero Exit(1);

@coryhouse
Copy link
Owner

It appears babel-node isn't pre-compiling the build tools. What happens when you run this at the root of the project directory?

node node_modules/.bin/babel-node tools/srcServer.js

@punmechanic
Copy link

Also encountering this issue. The error I receive is as follows (although this may be because I am running this in a mingw environment on Windows):

$ node node_modules/.bin/babel-node tools/srcServer.js
C:\Users\Dan\projects\@cardshifter\html-client\node_modules\.bin\babel-node:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:139:18)
    at node.js:999:3

Running this script directly in the shell works fine, so I expect my issue is more to do with the fact that Node is opening CMD windows (and not Bash windows)

@coryhouse
Copy link
Owner

@danpantry - Does this issue occur if you run this on the traditional Windows command line?

@punmechanic
Copy link

When I run npm start in the windows command line, I'll get the same error as OP. Running node node_modules/.bin/babel-node tools/srcServer.js in the windows command line also gives the same result (presumably because the windows command line doesn't support bash)

@coryhouse
Copy link
Owner

Odd, I'm seeing issues on my Windows test machine as well. Something has regressed.

Thanks for reporting!

Investigating..

@punmechanic
Copy link

Not a problem - let me know if I can assist further

@coryhouse coryhouse added the bug label Apr 5, 2016
@coryhouse
Copy link
Owner

Weird. It was running just fine in Git Bash on Windows, but failing on the Windows command line. I now have it working on both. Here's what I did:

  1. I cleared npm's cache
  2. I completely deleted the react-slingshot folder from my machine
  3. I did a git clone of this repo, then did an npm install.

And all works fine on the Windows command line for me now.

I'm running:
Windows 7
Node 5.7.0
npm 3.6.0

Can you please try the above and see if it fixes your issue? Thanks for working with me on this!

@punmechanic
Copy link

Nope, didn't fix it for me. :( Node 5.5, npm 3.8.1

@acostarelli
Copy link

I don't know if this is any help, but I received a very similar problem where all of a sudden I was getting errors about the ES6 syntax in source files I wasn't even in control of (e.g. files from npm packages).

However, the error wasn't coming from those files; it was coming from one of my own source files. If I remember correctly, I tried to do something like this:

{
    thing: <MyComponent/>
}

The problem is that you can't just stick JSX elements like that as the property of an object. This bug in my own code made it seem like a bug was coming from another file, probably the JSX parser file thing.

What I'm suggesting is that perhaps the problem is something to do with another file where some sort of syntax rule is being violated.

@coryhouse
Copy link
Owner

@danpantry - You know, @sirpython brings up a good point. Have you changed anything in this repo on your side? Does it run for you with no changes?

@punmechanic
Copy link

punmechanic commented Apr 17, 2016

@coryhouse Nope. I just downloaded the repo from source control and had the issue with no modifications. There was a commit made recently in that repo that uses babel-node instead of node to invoke srcServer.js which has seemed to have fixed the issue - I think the dev tool inclusion is unrelated.

FWIW, both @sirpython and I are using the same repo (the one linked)

@punmechanic
Copy link

The problem is that you can't just stick JSX elements like that as the property of an object.

@sirpython really? That's confusing, that should "just work".

@coryhouse
Copy link
Owner

@danpantry Now I'm confused. Why are you sharing a link to an issue in some separate repo? I thought we were discussing an issue in React Slingshot.

In Slingshot, babel-node is already being used to run srcServer.js: https://github.com/coryhouse/react-slingshot/blob/master/package.json#L9

If React Slingshot is giving you troubles, I'd like to help, but I need the following:

  1. a repo that includes your node_modules folder so that I can try reproducing your issues.
  2. Your OS, Node, npm versions
  3. What command line you're using (native windows, Git Bash, etc)

@punmechanic
Copy link

punmechanic commented Apr 17, 2016

@coryhouse I linked that because that project is using react-slingshot, and that commit shows how the issue was resolved. I have that repo, but from before that commit. Having now updated to that the issue is resolved.

That repo (doesn't include node_modules) is (or was) the repo with the issue. We obviously had all the ES6 tools however installed react-slingshot before this commit and as such did not have babel-node in our package.json. Or, somehow, we ended up with a mixed repo where we had ES6 tools but not the correct package.json installed

@acostarelli
Copy link

@danpantry Right, I don't think it was that that was causing the bug.

IIRC, then the object with the JSX value was being passed to some sort of jsdom rendering method. It was something that the method was doing that caused the problem, I believe.

Never mind about what I said, I don't think it's relevant now that I see the react-slingshot wasn't working on its own.

@coryhouse
Copy link
Owner

Okay, then this entire thread is about a bug in your modified copy of React Slingshot, not an actual issue in the current repo, correct?

@acostarelli
Copy link

@coryhouse No, I don't think so.

As @danpantry commented one hour ago, he just downloaded another copy of react-slingshot, made no modifications to it, and it still didn't work.

Here's what I could do right now for the specs you requested:

  1. https://github.com/Cardshifter/HTML-Client/tree/react
  2. I'm using Windows 10 and some Node v5 or something (sorry, I can't get the exact number right now)
  3. I'm using Git Bash for Windows (but we have another user working on the same project that is on a mac)

@punmechanic
Copy link

To clarify, when I said

just downloaded the repo..

I did not mean "I have downloaded it right now". I mean I downloaded it in the past (when I first reported the issue) and had the issue, with no modifications.

@coryhouse
Copy link
Owner

@sirpython - I don't understand what the link you provided has to do with Slingshot. That's not Slingshot - it's a separate repo with many changes. So how would that help convey the bug you're experiencing?

@acostarelli
Copy link

@coryhouse You asked for the repo we are working with:

  1. a repo that includes your node_modules folder so that I can try reproducing your issues

However, I don't think this is what Dan is referring to. It'd be best to talk with him.

@punmechanic
Copy link

punmechanic commented May 3, 2016

The reason I linked the Cardshifter repo was simply that was the repo I was using to replicate the issue. As far as I understand there were not many changes at all to any of the tooling in the Cardshifter repo, it was just react slingshot with some of our working files on top, but no modifications to any of the react-slingshot or webpack process

Thus it was my understanding that any issue with the tooling in that repo would be down to an issue in react-slingshot itself

@bogosavljev
Copy link

bogosavljev commented Jul 2, 2016

@coryhouse:
On my iMac, when I try to run: npm start -s I've got this error message which point to import { chalkSuccess }:

`/Users/dragonfly/web-site-works/andromeda-react/tools/startMessage.js:1
(function (exports, require, module, __filename, __dirname) { import { chalkSuccess } from './chalkConfig';
^^^^^^

SyntaxError: Unexpected token import
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at loader (/Users/dragonfly/web-site-works/andromeda-react/node_modules/babel-register/lib/node.js:158:5)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at /Users/dragonfly/web-site-works/andromeda-react/node_modules/babel-cli/lib/_babel-node.js:160:24
at Object. (/Users/dragonfly/web-site-works/andromeda-react/node_modules/babel-cli/lib/_babel-node.js:161:7)
at Module._compile (module.js:413:34)
ERROR: "start-message" exited with 1.`

What could be a problem?

@coryhouse
Copy link
Owner

@bogosavljev Have you run npm install? Also, are you using this repository unchanged?

@bogosavljev
Copy link

Yes, I have follow your steps and didn't change anytihng:

I have clone the project. git clone https://github.com/coryhouse/react-slingshot.git.
Run the setup script. npm run setup
Run the example app. npm start -s

@coryhouse
Copy link
Owner

@bogosavljev What version of npm and Node are you using?

@bogosavljev
Copy link

npm - 3.6.0
Node - 5.6.0

@coryhouse
Copy link
Owner

@bogosavljev Sorry, I can't reproduce this. I'd suggest installing from scratch in a different directory to see if it persists.

@bogosavljev
Copy link

@coryhouse I have create new folder and follow this steps:
First: I have run: npm install

  1. Clone the project. git clone https://github.com/coryhouse/react-slingshot.git.
  2. Run the setup script. npm run setup
  3. Run the example app. npm start -s

I'm using npm - 3.6.0 and Node - 5.6.0 on iMac late 2015, latest OS, same error occur.
Strange, on my Windows machine, same steps goes just fine. No errors.

@coryhouse
Copy link
Owner

coryhouse commented Jul 2, 2016

Hrmm...You might try installing Node 6. Perhaps your Node install has an issue. You can use nvm to run multiple versions.

@bogosavljev
Copy link

That does not helped me. I have installed Node 6.2.2 and npm 3.9.5
Don't know what is wrong... Dropping out.

@rjmreis
Copy link

rjmreis commented Sep 15, 2016

I think I know what's the problem, when you run npm run remove-demo the file .babelrc is removed which will result in an invalid import statement in Node. Just copy back the file and it should work fine.

@coryhouse
Copy link
Owner

@rjmreis remove-demo doesn't remove .babelrc. I just tested again to confirm. If that's happening for you then that's a bug. I'd be interested to hear what platform you're on.

@rjmreis
Copy link

rjmreis commented Sep 16, 2016

You're right, the problem was when I copied the files over I left out the hidden ones.

@JoeCostanzo
Copy link

JoeCostanzo commented Sep 20, 2016

These errors seem to be caused by the absence of having an .eslintrc file at the root of the project (that specifies es6 as the version to be parsed).

Confirmed solved for me, at least. Was getting the same errors, tried different ways of npm installing, different webpack config loaders, different versions of python, a reboot, etc. Finally fixed by adding the .eslintrc file in.

@kwelch
Copy link
Collaborator

kwelch commented Oct 12, 2016

Is this issue still persisting? I see a few fix cases in the chain, and want to confirm this is still an issue. It is unclear what the root issue is.

@richyrb00
Copy link

its still occurring.

@richyrb00
Copy link

To add more information its taken me a little while to resolve the issue but i went back into the repo and add back in the following files

.babelrc
.editorconfig
.eslintrc
.istanbul.yml
.travis.yml

I did see in someone elses comment that they tried putting back in just the .eslintrc on its own but that didn't work. I should have retried after each file.

@coryhouse
Copy link
Owner

@richyrb00 If you remove those critical files, then yes, the repo will break. That's no news.

This thread is about an issue that's supposedly happening out of the box. But neither Kyle nor I have been able to reproduce.

@kwelch
Copy link
Collaborator

kwelch commented Oct 15, 2016

Closing this issue since currently unreproducible. If anyone is still have any issues please file an issue so we can do our best to help.

As for the crucial files, if you want to remove these I recommend ensuring you understand their use and do so with proper forethought. If there are any particular questions, let me know I will answer to the best of my ability.

Of the ones listed .eslintrc and .babelrc are the most important, so if you only tried after putting back the .eslintrc, I would recommend bring back the .babelrc also.

@kwelch kwelch closed this as completed Oct 15, 2016
@richyrb00
Copy link

I thought that might help others. Because they are probably unzipping copying the files into a preferred folder and then running terminal commands. Because they are copying the files over it's not including the hidden files that I listed.

@kwelch
Copy link
Collaborator

kwelch commented Oct 15, 2016

If you could put in a PR to update the documentation that would be helpful.

On Sat, Oct 15, 2016, 4:07 AM Richard Bilton notifications@github.com
wrote:

I thought that might help others. Because they are probably unzipping
copying the files into a preferred folder and then running terminal
commands. Because they are copying the files over it's not including the
hidden files that I listed.


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
#84 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABPE3EQD11iwyNmsCd0CWz64UrVBVwohks5q0JfpgaJpZM4H4umN
.

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

No branches or pull requests

9 participants