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

SyntaxError: Unexpected token '?' #22

Closed
Mistic92 opened this issue Jan 4, 2021 · 6 comments
Closed

SyntaxError: Unexpected token '?' #22

Mistic92 opened this issue Jan 4, 2021 · 6 comments

Comments

@Mistic92
Copy link

Mistic92 commented Jan 4, 2021

Hi, when I'm running it directly in my pc via npm run start it's working but when I't trying to run it in docker I'm getting below error.
I'm not sure where it's coming from. Do you have any idea what might be the reason?

bot-gateway_1  |                 ...(options.extraProviders ?? []),
bot-gateway_1  |                                             ^
bot-gateway_1  | 
bot-gateway_1  | SyntaxError: Unexpected token '?'
bot-gateway_1  |     at Module._compile (internal/modules/cjs/loader.js:895:18)
bot-gateway_1  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
bot-gateway_1  |     at Module.load (internal/modules/cjs/loader.js:815:32)
bot-gateway_1  |     at Function.Module._load (internal/modules/cjs/loader.js:727:14)
bot-gateway_1  |     at Module.require (internal/modules/cjs/loader.js:852:19)
bot-gateway_1  |     at Module.Hook._require.Module.require (/usr/src/app/node_modules/require-in-the-middle/index.js:80:39)
bot-gateway_1  |     at require (internal/modules/cjs/helpers.js:74:18)
bot-gateway_1  |     at Object.<anonymous> (/usr/src/app/node_modules/nestjs-unleash/src/unleash-strategies/index.ts:3:1)
bot-gateway_1  |     at Module._compile (internal/modules/cjs/loader.js:959:30)
bot-gateway_1  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)

My dependencies

  "dependencies": {
    "@google-cloud/bigquery": "^5.5.0",
    "@google-cloud/pubsub": "^2.7.0",
    "@google-cloud/trace-agent": "^5.1.1",
    "@nestjs/common": "^7.6.1",
    "@nestjs/config": "^0.4.2",
    "@nestjs/core": "^7.6.1",
    "@nestjs/jwt": "^7.2.0",
    "@nestjs/passport": "^7.1.5",
    "@nestjs/platform-express": "^7.6.1",
    "@nestjs/schedule": "^0.4.1",
    "@nestjs/swagger": "^4.7.6",
    "@nestjs/terminus": "^7.0.1",
    "class-transformer": "^0.2.3",
    "class-validator": "^0.12.2",
    "compression": "^1.7.4",
    "dayjs": "^1.9.7",
    "dotenv": "^8.2.0",
    "gcp-metadata": "^4.2.1",
    "helmet": "^3.23.3",
    "lru-cache": "^6.0.0",
    "measurement-protocol": "^0.1.1",
    "nestjs-pino": "^1.3.0",
    "nestjs-unleash": "^1.2.0",
    "passport": "^0.4.1",
    "passport-http": "^0.3.0",
    "passport-local": "^1.0.0",
    "pino-pretty": "^4.3.0",
    "pino-stackdriver": "2.1.1",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^6.6.3",
    "source-map-support": "0.5.18"
  },
  "devDependencies": {
    "@nestjs/cli": "^7.5.4",
    "@nestjs/schematics": "^7.2.5",
    "@nestjs/testing": "^7.6.1",
    "@types/express": "^4.17.9",
    "@types/helmet": "0.0.47",
    "@types/jest": "25.1.4",
    "@types/lru-cache": "^5.1.0",
    "@types/node": "^13.13.36",
    "@types/passport-http": "^0.3.8",
    "@types/passport-local": "^1.0.33",
    "@types/supertest": "^2.0.10",
    "@types/universal-analytics": "^0.4.4",
    "@typescript-eslint/eslint-plugin": "^2.34.0",
    "@typescript-eslint/parser": "^2.34.0",
    "commander": "^6.2.1",
    "eslint": "^6.8.0",
    "eslint-config-prettier": "^6.15.0",
    "eslint-plugin-import": "^2.22.1",
    "husky": "^4.3.6",
    "jest": "^26.6.3",
    "jest-junit": "10.0.0",
    "prettier": "^1.19.1",
    "pretty-quick": "^2.0.2",
    "supertest": "^4.0.2",
    "ts-jest": "25.5.0",
    "ts-loader": "^6.2.1",
    "ts-node": "^8.10.2",
    "tsconfig-paths": "^3.9.0",
    "typescript": "^4.1.3"
  },
@Mistic92
Copy link
Author

Mistic92 commented Jan 4, 2021

Hm, locally I was running node 14 where in Docker I had node 12. After changing to node14 in docker file it's working.

@Mistic92 Mistic92 closed this as completed Jan 4, 2021
@nllahat
Copy link

nllahat commented May 14, 2021

@pmb0 I'm having this issue too (running locally. node version v14.16.0. nest version v7.6.7).
Any idea what is wrong ?

@pmb0
Copy link
Owner

pmb0 commented May 14, 2021

Hi @nllahat , the Nullish coalescing operator (??) needs Node.js ^14.0.0. are you sure you use v14?

@pmb0
Copy link
Owner

pmb0 commented May 14, 2021

However, it was not my intention that this only runs with new / recent Node.js versions. I will adjust the ts transpiler settings.

@nllahat
Copy link

nllahat commented May 14, 2021

@pmb0 sorry. my mistake. I ran it with node 13.4.

pmb0 added a commit that referenced this issue May 15, 2021
github-actions bot pushed a commit that referenced this issue May 15, 2021
## [1.4.1](v1.4.0...v1.4.1) (2021-05-15)

### Bug Fixes

* use "ES2019" as output target ([#22](#22)) ([617b147](617b147))
@Anthony07M
Copy link

Anthony07M commented Feb 13, 2023

Olá, estou com o mesmo problema.

app_1  | /home/node/app/node_modules/rimraf/dist/cjs/src/ignore-enoent.js:15
app_1  |         if (er?.code !== 'ENOENT') {
app_1  |                ^
app_1  | 
app_1  | SyntaxError: Unexpected token '.'
app_1  |     at Module._compile (internal/modules/cjs/loader.js:895:18)
app_1  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
app_1  |     at Module.load (internal/modules/cjs/loader.js:815:32)
app_1  |     at Function.Module._load (internal/modules/cjs/loader.js:727:14)
app_1  |     at Module.require (internal/modules/cjs/loader.js:852:19)
app_1  |     at require (internal/modules/cjs/helpers.js:74:18)
app_1  |     at Object.<anonymous> (/home/node/app/node_modules/rimraf/dist/cjs/src/rimraf-posix.js:14:28)
app_1  |     at Module._compile (internal/modules/cjs/loader.js:959:30)
app_1  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
app_1  |     at Module.load (internal/modules/cjs/loader.js:815:32)
app_1  | npm ERR! code ELIFECYCLE
app_1  | npm ERR! errno 1
app_1  | npm ERR! nest-api@0.0.1 start:dev: `nest start --watch`
app_1  | npm ERR! Exit status 1
app_1  | npm ERR! 
app_1  | npm ERR! Failed at the nest-api@0.0.1 start:dev script.
app_1  | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
app_1  | 
app_1  | npm ERR! A complete log of this run can be found in:
app_1  | npm ERR!     /home/node/.npm/_logs/2023-02-13T14_25_17_922Z-debug.log
nest-api_app_1 exited with code 1
  • Atualmente estou com o node v18.13.0

  • meu Dockerfile:

FROM node:18.14-alpine3.16

RUN apk add --no-cache bash

RUN npm install -g @nestjs/cli@7.5.6

USER node

WORKDIR /home/node/app
  • docker-compose.yaml:
version: '3'

services:
  app: 
    build: .
    entrypoint: ./.docker/entrypoint.sh
    ports:
      - 3000:3000
    volumes:
      - .:/home/node/app

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

4 participants