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" when using symlinks #830

Open
quooston opened this issue Feb 24, 2018 · 16 comments
Open

"Unexpected token import" when using symlinks #830

quooston opened this issue Feb 24, 2018 · 16 comments
Labels

Comments

@quooston
Copy link

quooston commented Feb 24, 2018

I'm submitting a bug report

  • Library Version:
    CLI: 0.32.0

Please tell us about your environment:

  • Operating System:
    Windows 10 Pro

  • Node Version:
    9.5.0

  • NPM Version:
    5.6.0

  • Browser:
    N/A

  • Language:
    ESNext

  • Loader/bundler:
    SystemJS and RequireJS

Current behavior:
au new --here does it's thing. After installing dependencies, I run au build, and get the error:

(function (exports, require, module, __filename, __dirname) { import gulp from 'gulp';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at new Script (vm.js:51:7)
    at createScript (vm.js:138:10)
    at Object.runInThisContext (vm.js:199:10)
    at Module._compile (module.js:624:28)
    at Module._extensions..js (module.js:671:10)
    at Object.require.extensions.(anonymous function) [as .js] (d:\code\scratch\meh\node_modules\babel-register\lib\node.js:152:7)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)

I have just recently reformatted my machine, this is a fresh box with everything installed first time.

I have a .babelrc file (put there by the CLI):

{
  "sourceMap": true,
  "sourceRoot": "src",
  "moduleIds": false,
  "comments": false,
  "compact": false,
  "code": true,
  "presets": [
    ["es2015", {"loose": true}],
    "stage-1"
  ],
  "plugins": [
    "syntax-flow",
    "transform-decorators-legacy",
    "transform-flow-strip-types"
  ]
}
  • What is the expected behavior?
    I'd like it to build!

  • What is the motivation / use case for changing the behavior?
    :|

@Alexander-Taran
Copy link
Contributor

Looks like it does not get transpiled correctly. I just tried on node 8.5 and it worked as it should.
You can debug cli with vscode
modify launch.json to add a configuration like this:
`{
// Use IntelliSense to find out which attributes exist for node debugging
// Use hover for the description of the existing attributes
// For further information visit https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
  "type": "node",
  "request": "launch",
  "name": "Debug CLI build",
  "program": "${workspaceFolder}/node_modules/aurelia-cli/bin/aurelia-cli.js",
  "args": [
    "build"
  ]
}

]
}
`
and step through

@Alexander-Taran
Copy link
Contributor

@quooston have you been able to resolve your issue?

@quooston
Copy link
Author

quooston commented Mar 12, 2018 via email

@Alexander-Taran
Copy link
Contributor

@quooston might me npm issue btw.
do you have yarn installed?
If not can you try with installing yarn and rescaffolding with au new?

@quooston
Copy link
Author

quooston commented Mar 12, 2018 via email

@Alexander-Taran
Copy link
Contributor

Keep me posted (-:

@quooston
Copy link
Author

quooston commented Mar 15, 2018 via email

@Alexander-Taran
Copy link
Contributor

@quooston this one is very strange. Might also try on another box?

@JeroenVinke
Copy link
Collaborator

Perhaps try a different folder as well, maybe on the C disk

@Alexander-Taran
Copy link
Contributor

@quooston Another thought is that you might be behind a proxy.
There is new version of CLI that just came out
can you update yours and try again?

@joonhwan
Copy link

joonhwan commented Apr 2, 2018

same here.

Win7 / node-8.11.1 / npm-5.6.0 / au-0.33.1

I did

  • au new router-tutorial (default configuratino)
  • au build
d:\prj\study\aurelia\router2\aurelia_project\tasks\build.js:1
(function (exports, require, module, __filename, __dirname) { import gulp from 'gulp';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Module._extensions..js (module.js:663:10)
    at Object.require.extensions.(anonymous function) [as .js] (d:\prj\study\aurelia\router2\node_modules\babel-register\lib\node.js:152:7)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)

au run did make same result. any hint or update? I'm just kicking in learning aurelia.

@Alexander-Taran
Copy link
Contributor

@joonhwan looks like npm issue from here..
can we retrace your steps?
I assume you installed aurelia-cli with npm i -g aurelia-cli
then you ran au new something
what were the choices?

also run where au from command line there might be more CLIs than you think of (-:

anyway try to update npm to latest (5.8 I think) with npm i -g npm
and redo from scratch.
all the scenarios should work.
It is just a js program after all.
external dependencies seem to fail more recently.. npm, webpack etc..

@quooston
Copy link
Author

quooston commented Apr 10, 2018 via email

@quooston
Copy link
Author

quooston commented Apr 10, 2018 via email

@quooston
Copy link
Author

quooston commented Apr 10, 2018 via email

@Alexander-Taran
Copy link
Contributor

@joonhwan do you also use symlinks ?

@JeroenVinke JeroenVinke changed the title Brand new CLI project fails to build "Unexpected token import" when using symlinks Jul 2, 2018
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

4 participants