I tried to upgrade the node version, rolled back the version to the old one and started getting typescript errors that weren't there before.
I understand that my question will seem stupid to many and even get disadvantages, but I really do not know much about this issue.
But now the project does not run locally with exactly the same version of the wizard (the same package.json) with which everything worked
I need to start, I will raise the typescript version in the future and solve all existing problems, but now I urgently need to solve another, and I cannot even start.
Could this also happen due to the fact that when I updated node I used the following commands, including clearing the cache as I understand it:
npm cache clean -f
sudo npm install -g n
// package.json
{
"name": "projectname",
"version": "1.0.0",
"main": "index.js",
"description": "project description",
"private": true,
"scripts": {
"dev": "DEBUG=projectname:* DEBUG_DEPTH=5 nodemon server/server.ts",
"build": "next build && tsc --project tsconfig.server.json",
"start": "NODE_ENV=production LANG=en node .next/production-server/server/server.js",
"postbuild": "cp -r static .next/",
"analyze": "BUNDLE_ANALYZE=both yarn build"
},
"dependencies": {
"#zeit/next-bundle-analyzer": "^0.1.2",
"#zeit/next-css": "^1.0.1",
"#zeit/next-sass": "^1.0.1",
"#zeit/next-typescript": "^1.1.1",
"app-root-path": "^2.1.0",
"aws-sdk": "^2.404.0",
"bbcode-to-react": "^0.2.9",
"bcrypt": "^3.0.6",
"body-parser": "^1.18.3",
"chart.js": "^2.7.3",
"compression": "^1.7.3",
"connect-memcached": "^1.0.0",
"connect-memjs": "^0.2.1",
"connect-mongo": "^2.0.1",
"cookie-parser": "^1.4.3",
"cookie-session": "^1.3.3",
"cron": "^1.7.0",
"cross-fetch": "^3.0.1",
"csv-parse": "^4.4.1",
"debug": "^4.1.1",
"diff": "^3.5.0",
"export-to-csv": "^0.2.1",
"express": "^4.16.3",
"express-http-proxy": "^1.5.1",
"express-session": "^1.15.6",
"find-remove": "^1.2.2",
"form-data": "^3.0.0",
"geoip-lite": "^1.3.8",
"humps": "^2.0.1",
"immutable": "^3.8.2",
"js-base64": "^2.5.2",
"json-immutable": "^0.4.0",
"jsonwebtoken": "^8.3.0",
"locale": "^0.1.0",
"lodash": "^4.17.10",
"lru-cache": "^5.1.1",
"md5": "^2.2.1",
"mic-recorder-to-mp3": "^2.2.1",
"moment-timezone": "0.3.0",
"mongoose": "^5.2.9",
"multer": "^1.3.1",
"next": "^8.0.3",
"next-compose-plugins": "^2.1.1",
"next-cookies": "^1.1.2",
"next-redux-wrapper": "^3.0.0-alpha.2",
"next-routes": "^1.4.2",
"node-sass": "^4.9.3",
"nodemailer": "^4.6.8",
"normalizr": "^3.2.4",
"passport": "^0.4.0",
"passport-custom": "^1.1.0",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"paypal-rest-sdk": "^1.8.1",
"pmx": "^1.6.7",
"query-string": "^6.2.0",
"rc-slider": "^8.6.3",
"react": "^16.8.4",
"react-beautiful-dnd": "^9.0.2",
"react-chartjs-2": "^2.7.4",
"react-collapse": "^4.0.3",
"react-copy-to-clipboard": "^5.0.1",
"react-cropper": "^1.0.1",
"react-csv": "^1.0.19",
"react-datasheet": "^1.3.14",
"react-day-picker": "^7.3.0",
"react-dom": "^16.8.4",
"react-dropzone": "^5.1.0",
"react-flags": "^0.1.17",
"react-ga": "^2.6.0",
"react-google-recaptcha": "^1.0.5",
"react-infinite-scroller": "^1.2.4",
"react-joyride": "^2.0.5",
"react-js-pagination": "^3.0.2",
"react-lazy-load": "^3.0.13",
"react-mic-record": "^1.0.6",
"react-modal": "^3.8.1",
"react-player": "^1.6.6",
"react-quill": "^1.3.3",
"react-redux": "^6.0.1",
"react-select": "^2.1.0",
"react-share": "^2.4.0",
"react-sizeme": "^2.5.2",
"react-to-print": "^2.4.0",
"read-excel-file": "^4.0.7",
"redux": "^4.0.0",
"redux-form": "^8.1.0",
"redux-saga": "^0.16.0",
"set-value": "^3.0.0",
"shelljs": "^0.8.2",
"shortid": "^2.2.13",
"slugify": "^1.3.4",
"socket.io": "^2.2.0",
"socket.io-client": "^2.2.0",
"socket.io-redis": "^5.2.0",
"twig": "^1.12.0",
"typegoose": "^5.2.1",
"uuid": "^3.3.2"
},
"devDependencies": {
"#babel/plugin-proposal-decorators": "^7.1.0",
"#types/body-parser": "^1.17.0",
"#types/connect-mongo": "^0.0.38",
"#types/cookie-parser": "^1.4.1",
"#types/debug": "^4.1.0",
"#types/express": "^4.16.0",
"#types/express-session": "^1.15.10",
"#types/mongodb": "^3.1.4",
"#types/mongoose": "^5.2.6",
"#types/multer": "^1.3.7",
"#types/node": "^10.7.1",
"#types/passport": "^0.4.6",
"#types/passport-local": "^1.0.33",
"#types/react": "^16.4.11",
"#types/react-dom": "^16.0.7",
"#types/redux-form": "^7.4.7",
"#types/set-value": "^2.0.0",
"#types/shortid": "^0.0.29",
"autoprefixer": "^9.4.3",
"babel-plugin-module-resolver": "^3.1.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-wrap-in-js": "^1.1.1",
"css-purify-webpack-loader": "^1.0.1",
"eslint": "^5.4.0",
"eslint-plugin-react": "^7.11.1",
"faker": "^4.1.0",
"next-purgecss": "^3.0.1",
"next-size": "^2.0.2",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"purgecss-whitelister": "^2.3.1",
"stylelint-config-recommended": "^2.1.0",
"tailwindcss": "^0.7.4",
"ts-node": "^7.0.1",
"typescript": "^3.0.1",
"webpack-pwa-manifest": "^4.0.0"
}
}
// ts-node -v =>
ts-node v7.0.1
node v10.19.0
typescript v3.0.1
cache "/tmp/ts-node-83......"
[UPDATED] I changed "typescript": "^3.0.1" > "typescript": "3.0.1", and in project v3.0.1 now, global v3.7.5
I switch them to VSCode and it does not underline anything, I also took a commit where I made corrections when I tried to raise versions of all packages, but I used the original package.json, and now it swears at the import format (If I understand correctly, this import format goes in later versions: import moment from 'moment-timezone'):
// utils.ts:
import * as moment from 'moment-timezone';
// traceback error
/home/roma/project/app/utils.ts:379
value: {startDate: moment().startOf('day').unix() * 1000, endDate: moment().unix() * 1000},
TypeError: moment is not a function
at Object.<anonymous> (/home/roma/project/app/utils.ts:379:29)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module.m._compile (/home/roma/project/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .ts] (/home/roma/project/node_modules/ts-node/src/index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/roma/project/server/models/user.ts:10:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module.m._compile (/home/roma/project/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .ts] (/home/roma/project/node_modules/ts-node/src/index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:653:32)
[nodemon] app crashed - waiting for file changes before starting...
P.S. In the future, I still plan to update all packages to the latest versions including node as required by Next.js v11. What is the best and most correct way to do this so that while work is underway to be able to quickly switch to support the site and resolve urgent problems, without facing such a situation as it is now?
Related
I'm using visual studio code with node v18.
I use structuredClone in my application and it runs fine but when it comes to running a test I get
"ReferenceError: structuredClone is not defined"
I don't know how mocha works, but is it for some reason using an older version of node or is there some other dependency creating an issue?
"dependencies": {
"#sendgrid/mail": "^7.6.2",
"#types/chai": "^4.3.1",
"#types/express": "^4.17.13",
"#types/mocha": "^9.1.1",
"#types/node": "^18.0.0",
"#types/npm": "^7.19.0",
"bcrypt": "^5.0.1",
"body-parser": "^1.19.2",
"chai": "^4.3.6",
"connect-flash": "^0.1.1",
"cookie-parser": "^1.4.6",
"dotenv": "^16.0.0",
"eventemitter2": "^6.4.5",
"express": "^4.17.3",
"express-validator": "^6.14.0",
"jsdom": "^20.0.0",
"jsonwebtoken": "^8.5.1",
"marked": "^4.0.12",
"memory-cache": "^0.2.0",
"mocha": "^10.0.0",
"mssql": "^8.0.2",
"sanitize-html": "^2.7.0",
"validator": "^13.7.0",
"xsg.spider": "file:./../spider"
},
"devDependencies": {
"#types/bcrypt": "^5.0.0",
"#types/connect-flash": "^0.0.37",
"#types/cookie-parser": "^1.4.2",
"#types/dompurify": "^2.3.3",
"#types/jsdom": "^16.2.14",
"#types/jsonwebtoken": "^8.5.8",
"#types/marked": "^4.0.3",
"#types/memory-cache": "^0.2.2",
"#types/mssql": "^7.1.5",
"#types/passport-local": "^1.0.34",
"#types/sanitize-html": "^2.6.2",
"#types/validator": "^13.7.2",
"nyc": "^15.1.0",
"ts-node": "^10.7.0",
"typescript": "^4.6.4"
}
It's probably a bug, as a turnaround to deep clone your object, you can use JSON.parse & JSON.stringify:
if (global.structuredClone)
clonedObject = structuredClone(object)
else
clonedObject = JSON.parse(JSON.stringify(object))
I have used mongoose package in my nest project but when I am trying to build the project using npm run build.Then its throwing below error in my console:
node_modules/mongoose/node_modules/mongodb/mongodb.d.ts:34:15 - error TS2305: Module '"tls"'
has no exported member 'TLSSocketOptions'.
34 import type { TLSSocketOptions } from 'tls';
I have even updated the mongoose package to the latest version.Then also I am getting the same error:
Below are my dependencies inside package.json file:
"dependencies": {
"#apollo/gateway": "^0.38.0",
"#google-cloud/translate": "^6.2.1",
"#nestjs/common": "^8.0.6",
"#nestjs/core": "^8.0.6",
"#nestjs/cqrs": "^8.0.0",
"#nestjs/graphql": "^8.0.2",
"#nestjs/microservices": "^8.0.6",
"#nestjs/mongoose": "^9.0.3",
"#nestjs/platform-express": "^8.0.6",
"#types/luxon": "^1.15.1",
"apollo-server-express": "^2.25.2",
"bunyan": "^1.8.12",
"bunyan-rotating-file-stream": "^1.6.3",
"connect-redis": "^3.4.1",
"consul": "^0.40.0",
"device-detector-js": "^3.0.3",
"elasticsearch": "^16.2.0",
"express-session": "^1.16.2",
"firebase-admin": "^9.4.2",
"graphql": "^14.7.0",
"graphql-tools": "^4.0.4",
"json-rules-engine": "^3.1.0",
"kafkajs": "^1.15.0",
"lodash": "^4.17.21",
"luxon": "^1.16.0",
"moneysafe": "^2.2.1",
"mongodb": "^3.5.9",
"mongoose": "^6.3.0",
"nestjs-i18n": "^8.1.1",
"node-wit": "^6.0.0",
"reflect-metadata": "^0.1.12",
"rimraf": "^2.6.2",
"rxjs": "^7.3.0",
"ts-morph": "^12.0.0",
"typescript": "^4.3.5",
"uuid": "^3.3.2"
},
"devDependencies": {
"#nestjs/testing": "^5.1.0",
"#types/jest": "^23.3.1",
"#types/lodash": "^4.14.134",
"#types/node": "^10.7.1",
"#types/supertest": "^2.0.5",
"jest": "^23.5.0",
"nodemon": "^1.18.3",
"prettier": "^1.14.2",
"supertest": "^3.1.0",
"ts-jest": "^23.1.3",
"ts-loader": "^4.4.2",
"ts-node": "^7.0.1",
"tsconfig-paths": "^3.5.0",
"tslint": "5.11.0"
}
Someone let me know how can I resolve this error.Any help on this will be really appreciated.
I fixed this by updating #types/node to the latest version. This specific error message is then fixed!
Actualy I try to intgrat
but I face to this exception my node version is 16.3.2 32bit
C:\Users\PC\Desktop\electron_project_X32\node_modules\express\lib\application.js:630 Error: Loading non-context-aware native module in renderer: '\\?\C:\Users\PC\Desktop\electron_project_X32\node_modules\#chilkat\ck-electron16-win-ia32\chilkat.node'. See https://github.com/electron/electron/issues/18397.
at process.func [as dlopen] (node:electron/js2c/asar_bundle:5)
and this is may package.json
"devDependencies": {
"cpx": "^1.5.0",
"electron": "^16.1.0",
"electron-packager": "^15.4.0",
"electron-rebuild": "^3.2.7",
"ncp": "^2.0.0"
},
"dependencies": {
"#chilkat/ck-electron16-win-ia32": "^9.50.89",
"#chilkat/ck-node16-win-ia32": "^9.50.89",
"cors": "^2.8.5",
"crypto-js": "^4.1.1",
"crypto-md5": "^1.0.0",
"dotenv": "^16.0.0",
"electron-tabs": "^0.15.0",
"express": "^4.17.3",
"ffi-napi": "^4.0.3",
"freemarker": "^2.0.1",
"md5": "^2.3.0",
"multer": "^1.4.4",
"node-cron": "^3.0.0",
"node-key-sender": "^1.0.11",
"node-notifier": "^10.0.1",
"npm": "^8.5.3",
"pkg": "^5.5.2",
"serialport": "^10.4.0",
"sudo-prompt": "^9.2.1",
"through2": "^4.0.2",
"websocket": "^1.0.34"
}
I try to set this app.allowRendererProcessReuse = false in main.js but it don't solve the problem
SOLVED BY #chilkat Software by upgrading the current version of chilkat/ck-electron16-win64 and win32
I took over a ASP.net solution with multiple projects in Visual Studio (Professional 2017), one of these projects is in React. I have some experience with React-Native, but I am rather new to React, plus I am new to the code base I inherited.
Since the project was using many outdated and potentially insecure packages (according to npm audit), I decided to update using NPM by carefully replacing some ^1.2.3 with * inside my package.json (see below) as I read somewhere that this is common procedure.
Although there are no errors displayed in Visual Studio's Error List, the React project has troubles to compile and I am seeing an empty page in the browser. The error code is
index.tsx:1 Uncaught Error: Module parse failed: Unexpected token (51:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| ReactDOM.render(
> <LocaleProvider locale={enUS}>
| <Provider store={store}>
| <Layout>
at eval (index.tsx:1)
at Object../src/index.tsx (bundle.js:96)
at __webpack_require__ (bundle.js:20)
at bundle.js:84
at bundle.js:87
(anonymous) # index.tsx:1
./src/index.tsx # bundle.js:96
__webpack_require__ # bundle.js:20
(anonymous) # bundle.js:84
(anonymous) # bundle.js:87
This looks like some webpack issue, but the exact error message is changing while I am trying to resolve the dependencies.
More curiously, my IDE is crashing after a few minutes, while contentiously creating files named VMxx, see my screenshot of the solution explorer
Inside those files I find e.g.
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ && window.__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers.size > 0
Clearly, something went wrong with the package update. But what does the described behavior mean? Can I deduce which packages I better should not have updated?
Package.json before
"dependencies": {
"antd": "^2.10.0",
"babel-polyfill": "^6.23.0",
"download": "^6.2.5",
"immutable": "^3.8.1",
"moment": "^2.24.0",
"react": "15.5.3",
"react-dom": "15.5.3",
"react-redux": "^5.0.4",
"react-router-dom": "^4.1.1",
"react-router-redux": "^5.0.0-alpha.6",
"redux": "^3.6.0",
"redux-saga": "^0.14.8",
"reselect": "^3.0.0",
"whatwg-fetch": "^2.0.3"
},
"devDependencies": {
"#types/react": "15.0.21",
"#types/react-dom": "0.14.23",
"#types/react-redux": "^4.4.40",
"#types/react-router-redux": "^5.0.0",
"awesome-typescript-loader": "3.1.2",
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-preset-env": "^1.4.0",
"css-loader": "^3.2.0",
"extract-text-webpack-plugin": "^2.1.0",
"less": "^2.7.2",
"less-loader": "^4.0.3",
"source-map-loader": "0.2.1",
"style-loader": "^0.17.0",
"ts-loader": "2.0.3",
"typescript": "2.2.1",
"webpack": "^2.7.0"
}
Package.json afterwards
"dependencies": {
"#types/node": "*",
"#types/react-select": "*",
"antd": "2.10.0",
"babel-polyfill": "6.23.0",
"download": "6.2.5",
"draft-js": "^0.11.0",
"immutable": "3.8.2",
"jquery": "^3.4.1",
"moment": "*",
"react": "*",
"react-dom": "*",
"react-lazy-load": "^3.0.13",
"react-redux": "*",
"react-router-dom": "*",
"react-router-redux": "*",
"redux": "3.6.0",
"redux-saga": "0.14.8",
"reselect": "3.0.1",
"webpack-cli": "^3.3.8",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"#types/react": "^16.9.2",
"#types/react-dom": "0.14.23",
"#types/react-redux": "4.4.40",
"#types/react-router-dom": "^4.3.5",
"#types/react-router-redux": "5.0.0",
"ajv": "^6.10.2",
"awesome-typescript-loader": "3.1.2",
"babel-core": "6.26.3",
"babel-loader": "7.1.5",
"babel-plugin-transform-es2015-parameters": "6.24.1",
"babel-preset-env": "1.7.0",
"css-loader": "*",
"less": "2.7.3",
"less-loader": "4.1.0",
"source-map-loader": "0.2.1",
"style-loader": "0.17.0",
"ts-loader": "2.0.3",
"typescript": "2.2.1",
"webpack": "^4.40.2"
}
I am using Laravue Dashboard based on Laravel and Vue.js, running on an online server, not localhost, it is a fresh install, no edits has been conducted.
My Problem is :
After running npm run watch/dev or even npm run production, vendor.js is about 26MB which I find unreasonably big.
I have tried to run npm run report but nothing shows, no errors or data.
Webpack bundle analyzer plugin is configured but stats.json is empty.
Here are dependencies from package.json:
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"resources/**/*.{js,vue}": [
"eslint --fix",
"git add"
]
},
"devDependencies": {
"#babel/plugin-syntax-dynamic-import": "^7.2.0",
"babel-eslint": "^10.0.2",
"babel-plugin-dynamic-import-node": "^2.3.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^3.7.0",
"compression-webpack-plugin": "^2.0.0",
"cross-env": "^3.2.3",
"eslint": "^5.16.0",
"eslint-loader": "^2.2.1",
"eslint-plugin-vue": "^5.2.3",
"husky": "^3.0.2",
"laravel-mix": "^4.1.2",
"laravel-mix-eslint": "^0.1.3",
"lint-staged": "^9.2.1",
"resolve-url-loader": "^2.3.1",
"sass-loader": "^7.1.0",
"script-loader": "^0.7.2",
"svg-sprite-loader": "^4.1.3",
"vue-template-compiler": "2.6.10",
"webpack": "^4.39.1",
"webpack-bundle-analyzer": "^3.4.1"
},
"dependencies": {
"axios": "^0.18.1",
"camelcase": "^5.3.1",
"clipboard": "^2.0.4",
"core-js": "^3.1.4",
"driver.js": "^0.9.7",
"dropzone": "^5.5.1",
"echarts": "^4.1.0",
"element-ui": "^2.11.1",
"file-saver": "^2.0.1",
"fuse.js": "^3.4.5",
"js-cookie": "^2.2.0",
"jsonlint": "^1.6.3",
"jszip": "^3.2.2",
"node-sass": "^4.12.0",
"normalize.css": "^8.0.1",
"nprogress": "^0.2.0",
"path-to-regexp": "^3.0.0",
"screenfull": "^4.2.1",
"sortablejs": "^1.8.4",
"tui-editor": "^1.4.5",
"vue": "2.6.10",
"vue-count-to": "^1.0.13",
"vue-i18n": "^8.12.0",
"vue-router": "^3.0.7",
"vue-splitpane": "^1.0.4",
"vuedraggable": "^2.23.0",
"vuex": "3.1.0",
"xlsx": "^0.14.4"
}
In the official laravue demo https://laravue.dev/, vendor.js is ~4MB.
I cannot find any reason for this issue, would somebody offer any advise please?
Solved
After hours of inspecting, I found out that " npm run production " wasn't finishing because of memory shortage, this is why no errors were returned, the process was killed at some point with no messages.
simply restarted server and re-ran command.. Worked like magic.
May be if you remove some package that is not needed, will reduce vendor file size more.