кто-нибудь еще имел эту проблему?
(node:24328) ExperimentalWarning: The ESM module loader is experimental.
file:///Users/xxx19/Documents/projects/planning-poker/src/server.ts:13
wss.on('connection', (ws: WebSocket) => {
^
SyntaxError: Unexpected token ':'
at Loader.moduleStrategy (internal/modules/esm/translators.js:84:18)
at async link (internal/modules/esm/module_job.js:36:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! game-library@1.0.0 server: `tsc && node ./src/server.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the game-library@1.0.0 server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Вот мой пакет. json.
Я работаю npm run server
, что "tsc && node ./src/server.ts"
.
Запуск npm run tsc
не показывает никаких ошибок.
{
"name": "game-library",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
"client": "webpack-dev-server --inline --config webpack.config.cjs",
"server": "tsc && node ./src/server.ts",
"build": "webpack --config webpack.config.cjs",
"tsc": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "module",
"dependencies": {
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"express": "^4.17.1",
"prettier": "^2.0.5",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"ts-node": "^8.10.1",
"ws": "^7.2.5"
},
"devDependencies": {
"@babel/plugin-transform-typescript": "^7.9.6",
"@types/express": "^4.17.6",
"@types/node": "^13.13.2",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.6",
"@types/ws": "^7.2.4",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"eslint": "^6.8.0",
"eslint-plugin-react": "^7.19.0",
"source-map-loader": "^0.2.4",
"ts-loader": "^7.0.1",
"typescript": "^3.8.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
}
}
webpack.config:
'use-strict';
module.exports = {
// Enable sourcemaps for debugging webpack's output.
entry: './src/index.tsx',
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js'],
modules: ['src', 'node_modules'],
},
module: {
rules: [
{
test: /\.ts(x?)$/,
exclude: /node_modules/,
include: path.resolve(__dirname, 'src'),
use: [
{
loader: 'ts-loader',
},
],
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
},
],
},
// When importing a module whose path matches one of the following, just
// assume a corresponding global variable exists and use that instead.
// This is important because it allows us to avoid bundling all of our
// dependencies, which allows browsers to cache those libraries between builds.
externals: {
react: 'React',
'react-dom': 'ReactDOM',
},
};
ts.config:
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"target": "es6",
"jsx": "react",
},
"resolve": {
"extensions": [".ts", ".tsx", ".js"]
},
}