Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upexpressjs static keyword #1279
Comments
This comment has been minimized.
This comment has been minimized.
|
This is not actually a rule, but the parsing of the file is failing. I actually think that it isn't valid javascript to import a name named e.g. this is what happens in Node.js 12: $ cat a.mjs
import { static } from './b.mjs'
$ cat b.mjs
export function static () { return 1 }
$ node --experimental-modules a.mjs
(node:5927) ExperimentalWarning: The ESM module loader is experimental.
file:///private/tmp/hdjas/a.mjs:1
import { static } from './b.mjs'
^^^^^^
SyntaxError: Unexpected reserved word
at Loader.moduleStrategy (internal/modules/esm/translators.js:48:18)
at async link (internal/modules/esm/module_job.js:38:36)That being said, Express.js is shipped as a common-js module, and not a ES module. Instead of trying to import multiple things from express, I would use e.g. import express from 'express'
// ...
app.use(express.static(/* ... */))
// ... |
This comment has been minimized.
This comment has been minimized.
|
I agreed with you and I am going to change my code. |
PachoJGaviria
closed this
May 8, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PachoJGaviria commentedMay 8, 2019
What version of standard?
12.0.1
What operating system, Node.js, and npm version?
macOS Mojave, 10.15.3, 6.9.0
What did you expect to happen?
I am using express(4.16.1) to serving static content and need import 'static' function
import express, { json, urlencoded, static } from 'express'What actually happened?
But standard marketed the next error: Parsing error: The keyword 'static' is reserved (null)
How I can disable the rule null?