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 import - first build #400

Closed
steveacalabro opened this issue Mar 28, 2017 · 9 comments
Closed

Unexpected token import - first build #400

steveacalabro opened this issue Mar 28, 2017 · 9 comments

Comments

@steveacalabro
Copy link

Node version: 6.9.5

npm version: 3.10.10

Operating system: Windows 10

Command line used: Git Bash

Steps to reproduce:

  • Clone the project
  • Run npm install
  • Run npm run setup
  • Error appears
(function (exports, require, module, __filename, __dirname) { import { chalkSuccess } from './chalkConfig';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at loader (C:\Users\{project folder}\node_modules\babel-register\lib\node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Users\{project folder}\node_modules\babel-register\lib\node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function.Module.runMain (module.js:604:10)
    at C:\Users\{project folder}\node_modules\babel-cli\lib\_babel-node.js:159:24
    at Object.<anonymous> (C:\Users\{project folder}\node_modules\babel-cli\lib\_babel-node.js:160:7)```
@coryhouse
Copy link
Owner

coryhouse commented Mar 29, 2017 via email

@steveacalabro
Copy link
Author

I confirmed that the file was there.

I found the reason why in case anyone else comes across this issue. It is specifically a problem with windows machines I believe. I tried the setup on my Ubuntu box and it works fine.

When working with windows you need to have the following installed npm install --save-dev cross-env.

The reason behind this is that the NODE_ENV var on my machine was set to production and I was unable to set it to development without that module. Once installed and the NODE_ENV=development command was run everything worked out ok.

@coryhouse
Copy link
Owner

Great to hear you got it solved Steve! And thanks for sharing your solution. Curious - Why did you have NODE_ENV set to production on your machine?

@steveacalabro
Copy link
Author

I'm not entirely sure. I have a feeling it was with another project I was doing with React/webpack earlier this week

@ICeZer0
Copy link

ICeZer0 commented Apr 4, 2017

I am having the same issue. When I use the slingshot locally on my Mac it is fine. Once I upload it to Github I can't "npm start" without getting the error

/Users/ICe/GitHub/React.StocksApp/tools/startMessage.js:1 (function (exports, require, module, __filename, __dirname) { import { chalkSuccess } from './chalkConfig'; ^^^^^^ SyntaxError: Unexpected token import at Object.exports.runInThisContext (vm.js:76:16) at Module._compile (module.js:542:28) at loader (/Users/ICe/GitHub/React.StocksApp/node_modules/babel-cli/node_modules/babel-register/lib/node.js:144:5) at Object.require.extensions.(anonymous function) [as .js] (/Users/ICe/GitHub/React.StocksApp/node_modules/babel-cli/node_modules/babel-register/lib/node.js:154:7) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Function.Module.runMain (module.js:604:10) at /Users/ICe/GitHub/React.StocksApp/node_modules/babel-cli/lib/_babel-node.js:159:24 at Object.<anonymous> (/Users/ICe/GitHub/React.StocksApp/node_modules/babel-cli/lib/_babel-node.js:160:7)

@coryhouse
Copy link
Owner

@iM-Durant7 When you say "Once I upload it to Github I can't "npm start" without getting the error", how are you running it when up once up on GitHub? Have you confirmed .babelrc is uploaded?

@ICeZer0
Copy link

ICeZer0 commented Apr 4, 2017

I created a repo in github and copied the files over from my local machine. After npm install, I used "Npm start -s". You can look at my current repo "React.StocksApp" it has the .babel and I ran a console "hello world" to verify that .babel was working.

@coryhouse
Copy link
Owner

@iM-Durant7 Your .babelrc doesn't match Slingshots: https://github.com/coryhouse/react-slingshot/blob/master/.babelrc

I just tried Slingshot's .babelrc on your project and it started fine.

@ICeZer0
Copy link

ICeZer0 commented Apr 5, 2017

oh wow, ok thanks! I think once I uninstalled the demo project it took my babel away and I was lost 😢.

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