•  


Unexpected token import - first build · Issue #400 · coryhouse/react-slingshot · GitHub
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

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

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
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본