-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
import from, export class #1000
Comments
Not at the moment, the ES6 module system in V8 is still in its infancy. Your example can probably be made to parse by passing |
@bnoordhuis It appears that import {param} from '../config/param';
^^^^^^
SyntaxError: Unexpected token import |
Is there a plan to implement the ES6 module syntax when V8 provides support? A lot of module authors have begun to write modules with ES6 syntax, adding a special build process to enable a package to be used in io.js / node adds complexity and segmentation in usability, it feels like the whole CoffeeScript-ish era again 😄. |
@teugen There's been some discussion about that here: nodejs/NG#5 |
👍 Running into the reserved word SyntaxError in iojs v2.3.3 even with the An easy solution for now is to use
{
"scripts": {
"execute-script": "babel-tape-runner index.js || exit 0"
}
} // ...
"scripts": {
"execute-script": "6to5 src/index.js | iojs"
}, |
I'm fairly certain that iojs will need to hook into V8 to specify how to resolve the module path. This has not been done, and don't think the hooks exist yet. |
@MadLittleMods I tryed what you said but kept having the same error... Is there something wrong in the declarations that I'm doing? /*CliParser.js*/
export class CliParser {
static parse(arguments) {
//Code goes here
}
} /*index.js*/
import {CliParser} from './CliParser.js';
//Parse the argument vector
var parsedArguments = CliParser.parse(process.argv); I've done as you said and added a script in my package.json file: /*package.json*/
"scripts": {
"IPtoNode" : "6to5 index.js | iojs",
"test": "echo \"Error: no test specified\" && exit 1"
}, This is what i get when i run the script. #console
npm run IPtoNode
PathToApp\IPtoNode\CliParser.js:1
(function (exports, require, module, __filename, __dirname) { export class Cli
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at [stdin]:12:17
at Object.exports.runInThisContext (vm.js:54:17)
at Object.<anonymous> ([stdin]-wrapper:6:22) Note that if I run it out of the npm script it also produces the same error. |
The V8 API does not exist to allow us to define what happens with the path passed to import, so V8 has no idea how to resolve where the module is you're requesting. |
@MagoDopado It is the because the dependency,
{
"scripts": {
"execute-script": "babel-tape-runner index.js || exit 0"
}
} |
Hi Everyone, I have an issue that is related to this topic. I am creating a an ASPNETCORE Angular app, and getting the bellow error when executing DOTNET WATCH RUN SyntaxError: Invalid or unexpected token I have tried:
|
Let's say we want to usea module with class like:
And load it:
But when we try to run it:
We've got an error:
So, can we use such syntax?
The text was updated successfully, but these errors were encountered: