Atyantik/react-pwa

Unexpected identifier when using webpack-node-externals

bonyanteam opened this issue · 8 comments

I used webpack-node-externals to use express in the program
but an "Unexpected identifier" error is displayed when executing
@tirthbodawala

error

Hey, @bonyanteam I think this issue arises when you have multiple versions of React installed, can you please try the following?

(commands for bash shell)

rm -rf node_modules package-lock.json
npm i 

And then restart the application?
Basically, removing node_modules package-lock.json, re-installing the modules and thus restarting the app.

I did, but the error didn't change
In general, what should I do to use express in the backend?
@tirthbodawala

@bonyanteam can you please share your package.json, npm version, node version, OS details?

npm: 6.13.1
node:10.15.0
////////////////////////
package.json:

{
  "name": "react-pwa",
  "version": "2.2.7",
  "description": "A highly scalable, Progressive Web Application foundation with the best Developer Experience (DX).",
  "scripts": {
    "start": "pawjs --no-cache --env=development start",
    "build": "node --max_old_space_size=4096  ./node_modules/.bin//../@pawjs/pawjs/paw.js --no-cache --env-config-path=./.prod.env --env=production build",
    "build:demo": "pawjs --no-cache --env-config-path=./.demo.env --env=production build",
    "lint": "pawjs lint",
    "test": "pawjs --no-cache test"
  },
  "author": {
    "name": "Atyantik Technologies",
    "email": "admin@atyantik.com",
    "url": "https://www.atyantik.com/"
  },
  "contributors": [
    {
      "name": "Tirth Bodawala",
      "email": "tirthbodawala@atyantik.com",
      "url": "https://www.atyantik.com/"
    },
    {
      "name": "Yash Thakur",
      "email": "thakur.yash514@gmail.com",
      "url": "http://yashthakur.in/"
    },
    {
      "name": "Ajay Patel",
      "email": "ajaypatel@atyantik.com",
      "url": "https://www.atyantik.com/"
    }
  ],
  "license": "MIT",
  "dependencies": {
    "@hapi/joi": "^16.1.8",
    "@pawjs/image-optimizer": "^2.2.5",
    "@pawjs/pawjs": "^3.0.0-alpha.23",
    "@pawjs/sass": "^2.2.4",
    "@pawjs/srcset": "^2.1.3",
    "@types/react": "^16.9.13",
    "@types/react-dom": "^16.9.4",
    "bcrypt": "^3.0.7",
    "big.js": "^5.2.2",
    "bootstrap": "^4.4.1",
    "bulma": "^0.8.0",
    "cloudinary": "^1.17.0",
    "eslint-import-resolver-webpack": "^0.12.0",
    "fork-ts-checker-webpack-plugin": "^3.1.1",
    "lodash": "^4.17.15",
    "mysql2": "^2.0.1",
    "node-pre-gyp": "^0.14.0",
    "nodemailer": "^6.3.1",
    "prop-types": "^15.7.2",
    "rc-slider": "^8.7.1",
    "react": "^16.12.0",
    "react-autocomplete": "^1.8.1",
    "react-autosuggest": "^9.4.3",
    "react-bootstrap": "^1.0.0-beta.16",
    "react-copy-to-clipboard": "^5.0.2",
    "react-icons": "^3.8.0",
    "react-perfect-scrollbar": "^1.5.3",
    "react-resize-detector": "^4.2.1",
    "react-toastify": "^5.4.1",
    "react-tooltip": "^3.11.1",
    "request": "^2.88.0",
    "sequelize": "^5.21.2",
    "snyk": "^1.251.1",
    "socket.io": "^2.3.0",
    "socket.io-client": "^2.3.0",
    "universal-fetch": "^1.0.0",
    "uuid": "^3.3.3",
    "webpack-dev-server": "^3.9.0",
    "webpack-node-externals": "^1.7.2"
  },
  "snyk": true,
  "devDependencies": {
    "webpack-bundle-analyzer": "^3.6.0",
    "@pawjs/redux": "^2.2.2",
    "react-redux": "^7.1.3",
    "redux": "^4.0.4"
  }
}

os

@bonyanteam I see, config and environment seems fine, I think it is webpack-node-externals Can you please share why do you want to use express in the project? for API?

build script generate dist folder successfully but i can't run "node server.js"
error appeared after i'm adding some code in webpack.js in src folder

wp

Yes . I use Express to create the API

@bonyanteam you should not do that, cause @pawjs/pawjs bundles everything in server.js and thus express excluding node-modules can cause a problem. If there is a specific scenario that you want to handle please join our Gitter channel: https://gitter.im/react-pwa/Lobby

I can explain to you how to create APIs with ExpressJS.