QUESTION:
When doing "node app" on my local machine, everything works.
But when I deploy my project to the Google App Engine, the instance is killed and I find the following error in my logs:
npm ERR! Invalid version: "1"
I looked at:
npm: Why is a version "0.1" invalid?
npm ERR! Invalid version: y
how to workaround npm "Error: Invalid version: "0.1" BUG?
What is the mistake I need to correct ?
The deployment process started by gcloud app deploy --version=deploy
always ends with:
ERROR: (gcloud.app.deploy) Error Response: [4] Timed out waiting for the app infrastructure to become healthy.
Here is my package.json
CODE:
package.json
{
"name": "Name",
"version": "1.0.0",
"description": "Desc",
"main": "app.js",
"engines": {
"node": "6.9.4",
"npm": "4.2.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js",
"minify": "html-minifier --input-dir ./viewsCopy --output-dir ./views-minified --collapse-whitespace --html5 --minify-js true"
},
"author": "author",
"license": "copyright",
"dependencies": {
"bad-words": "^1.5.1",
"body-parser": "1.1*.1",
"connect-flash": "0.1.1",
"decimal.js": "^9.0.1",
"ejs": "2.5.5",
"events": "^1.1.1",
"express": "4.15.2",
"express-session": "1.15.2",
"express-validator": "3.2.0",
"fast-crc32c": "^1.0.4",
"firebase": "3.9.0",
"firebase-admin": "^5.2.1",
"fs": "0.0.1-security",
"glob": "7.1.1",
"helmet": "3.5.0",
"html-minifier": "^3.5.0",
"morgan": "1.8.1",
"multer": "1.3.0",
"nodemailer": "4.0.0",
"path": "0.12.7",
"raven": "^2.0.0",
"request": "^2.83.0",
"sanitize-html": "^1.14.1",
"uglify-js": "^3.0.6"
}
}
in my case was
"version": "1"
I've edited to
"version": "1.0.0"
and it fixes.
In package.json the 'engine' properties allows you to block the node.js application running on versions of CLI tools which are unsupported.
You can either remove or modify the values. From quickly looking at the gcloud documentation they are using the latest stable from node.js (v9.4.0) which is bundled with npm v5.6.0. You could allow your application to run with existing versions and greater by adding the greater than character before the version.
"engines": {
"node": ">6.9.4",
"npm": ">4.2.0"
},
package.json -> version semantics may need to be like 1.0.0
https://docs.npmjs.com/about-semantic-versioning
What fixed it for me was deleting node_modules and package-lock.json and reinstalling with npm install
As per the documentation provided over here for node-semver there may be an issue with the dependency packages versions being loaded
Double check these versions or remove all of these and then try, if it works then keep on adding one by one and ultimately when it stops working you know which version numbering is faulty
List is as follows which might be the possible suspects
"body-parser": "1.1*.1",
"fs": "0.0.1-security"
try to replace all dependency version with * , Same with npm version.
then run npm install.
I am not sure it will work or not but give it try.
Please remove package-lock.json file. That will fix a problem.
Related
I get an "Uncaught SyntaxError: Unexpected token ." message when I try to use my express app in debug mode in VSCode (F5) if my code includes optional chaining (?.).
I do not have this problem when I use the app with the command "npm start" which is working properly.
I do not have experience on building projects with very specific configuration (compilers, lighters...), this one was created just with npm init.
Below you can see the details that I consider useful for solving the issue. Let me know if you need anything else.
Is there anyway I can debug the app if it includes optional chaining syntax? Should I update any version? Should I change any config file?
Details:
node v16.10.0
npm v7.24.0
package.json
"main": "server/server.js",
"scripts": {
"start": "nodemon -e js,json,html,yml,css server/server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
},
"license": "ISC",
"dependencies": {
"#marsaud/smb2": "^0.17.2",
"bcrypt": "^5.0.1",
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"equals": "^1.0.5",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"moment": "^2.24.0",
"mongodb": "^3.6.5",
"mssql": "^7.2.1",
"nodemailer": "^6.4.10",
"nodemon": "^2.0.7",
"redoc": "^2.0.0-rc.24",
"swagger-jsdoc": "^4.0.0",
"tedious": "^14.0.0",
"underscore": "^1.9.1"
}
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Iniciar el programa",
"program": "${workspaceFolder}/backEnd/server/server.js"
}
],
}
Did you try to switch to different node version? I use node v14 and don't have the problem, but I read on other websites mentioned that they are using v16 and also have problem with optional chaining.
I had this same issue and downgrading npm to version 6.14.16 is what worked for me. Another work around that I was running while searching for a solution was to remove nodemon from the package.json scripts commands and replacing them with just node
"scripts": {
"start": "node js,json,html,yml,css server/server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
and running
nodemon --exec npm run start
Not sure what the exact issue is though, but it seems to be related to running the nodemon command from within the scripts in package.json file. I was able to verify this by simply running
npm run start
with the package.json changes mentioned above perfectly fine, but once it was changed to run with nodemon, I run into issues with optional chaining.
I finally found the solution, I was not using the right debugger so it was mainly a Visual Studio Code wrong configuration setup issue.
I recently installed some other debuggers so I had to set the node.js debugger again.
I have a project that already was deployed on Vercel. Since last week Im working on improve the layout with the goal of finish a MVP of this project. So, I changed my usage of auth0, using the package to nextjs #auth0/nextjs-auth0. I ran
npm install #auth0/nextjs-auth0
and I have on my package.json
{
"name": "MAmanager",
"version": "1.0.0",
"engines": {
"node": "14.x",
"npm": "6.x"
},
"description": "",
"main": "index.js",
"scripts": {
"dev": "next",
"start": "next start",
"build": "next build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#auth0/nextjs-auth0": "github:auth0/nextjs-auth0",
"dayjs": "^1.9.5",
"formik": "^2.1.5",
"next": "^10.2.3",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-icons": "^4.2.0",
"swr": "^0.5.6",
"yup": "^0.29.3"
},
"devDependencies": {
"autoprefixer": "^10.2.5",
"postcss": "^8.3.0",
"tailwindcss": "^2.1.2"
}
}
The usages on my pages are
import { UserProvider } from '#auth0/nextjs-auth0'
import { useUser } from '#auth0/nextjs-auth0'
import { withPageAuthRequired } from '#auth0/nextjs-auth0'
And when I deploy my branch on Vercel I get this error
08:57:49.989 Failed to compile.
08:57:49.990 ModuleNotFoundError: Module not found: Error: Can't resolve '#auth0/nextjs-auth0' in '/vercel/path0/pages'
08:57:49.990 > Build error occurred
08:57:49.991 Error: > Build failed because of webpack errors
08:57:49.991 at /vercel/path0/node_modules/next/dist/build/index.js:17:924
08:57:49.991 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584)
08:57:50.020 error Command failed with exit code 1.
I have seen errors like that caused by casing discrepancies but I don't understanding what is happening here. I appreciate any help.
After see other examples I just edited manually the package.json.
After run npm install #auth0/nextjs-auth0 the package was automatically added "#auth0/nextjs-auth0": "github:auth0/nextjs-auth0",.
I just edit to
"#auth0/nextjs-auth0": "^1.3.1"
and worked on deployment.
Note: The way the package was installed worked on dev in localhost but broke only on the deployment.
try making a custom build script for your deployment as a temporary workaround:
npm install && npm i #auth0/nextjs-auth0#1.3.1 && npm run build
This can be added under the deployment settings tab using a custom build command for production. Running the specific targeted package version install after npm i should override the problematic version being installed in prod
I receive this error whenever I run react-native start, but this started happening recently after I had installed firebase-tools and stripe in my node modules, but before that it would run just fine, also here's the error's stacktrace:
::ffff:127.0.0.1 - - [22/Mar/2020:19:59:30 +0000] "GET /index.bundle?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.12.1"
error: bundling failed: TypeError: Cannot read property 'transformFile' of undefined
at C:\Users\me\Project\node_modules\react-native\node_modules\#react-native-community\cli\node_modules\metro\src\Bundler.js:87:34
at Generator.next (<anonymous>)
at asyncGeneratorStep (C:\Users\me\Project\node_modules\react-native\node_modules\#react-native-community\cli\node_modules\metro\src\Bundler.js:14:24)
at _next (C:\Users\me\Project\node_modules\react-native\node_modules\#react-native-community\cli\node_modules\metro\src\Bundler.js:34:9)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Here's my package.json:
{
"name": "Project",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"card-validator": "6.2.0",
"firebase-tools": "7.15.1",
"jetifier": "^1.6.5",
"prop-types": "15.7.2",
"react": "^16.13.1",
"react-art": "^16.13.1",
"react-dom": "^16.13.1",
"react-geocode": "0.2.1",
"react-native": "0.61.5",
"react-native-country-picker-modal": "1.9.8",
"react-native-elements": "1.2.7",
"react-native-firebase": "5.6.0",
"react-native-geocoding": "0.4.0",
"react-native-gesture-handler": "1.5.2",
"react-native-maps": "0.26.1",
"react-native-paper": "3.2.1",
"react-native-reanimated": "1.4.0",
"react-native-restart": "0.0.14",
"react-native-shadow": "^1.2.2",
"react-native-svg": "12.0.3",
"react-native-vector-icons": "6.6.0",
"react-native-web": "^0.9.13",
"react-navigation": "4.0.10",
"react-navigation-drawer": "2.3.3",
"react-navigation-stack": "1.10.3",
"stripe": "^8.33.0",
"tipsi-stripe": "7.5.1",
"typescript": "^3.8.3"
},
"devDependencies": {
"#babel/core": "7.7.4",
"#babel/runtime": "7.7.4",
"#react-native-community/eslint-config": "0.0.5",
"babel-jest": "24.9.0",
"eslint": "^5.0.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.56.3",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
I am also well aware of another question that has the same problem on StackOverflow, but that question's solution didn't work for me, because npm ignored it when i ran react-native start since those modules were deprecated, and I still got the same error
Downgrading NodeJS to LTS version always helps. I faced same issue when I was trying on the NodeJS^17 but when I downgraded it to NodeJS^14 and reinstalled node_modules everything was fixed.
The solution in the first comment under the question worked for me, which was deleting the node_modules and package-lock.json, HOWEVER, I didn't want to do this knowing i would run into more errors, and sure enough I did, but at least I was able to fix them and get it to run, unlike the stubborn error I asked about. So yes, this method works, but I definitely hope that someone has a better way.
I was having this error. I did two things which I think led to me fixing this issue:
I'm working in a monorepo so I added the following code to my package.json:
"workspaces": {
"nohoist": [
"react-native",
"react-native/**",
"react",
"react/**"
]
}
I upgraded my metro-react-native-babel-preset package from ^0.58.0 to the latest version - ^0.59.0 (yarn add -D metro-react-native-babel-preset)
I have the same problem with Nodejs version 17.1.0. Just uninstalled it and reinstall Nodejs version 16.13.0.
I had the same issue. I was running npm v7. and node v10. I upgraded both to latest, and it started working.
This error happened to me when I was using the inline require in metro config for performance optimization.
I solve this problem changing the metro config property "blacklist" to "blockList":
return {
preloadedModules: moduleMap,
transform: { inlineRequires: { blockList: moduleMap } },
}
This is an old thread but I wanted to contribute as it is one of the first threads that appears in Google when searching "Cannot read property 'transformFile' of undefined".
This might not be a permanent fix as it seems to crop up when installing new dependencies, I'm also using Expo.
To fix this I've been installing the dependency, then using yarn-upgrade-all which goes through your package.json and upgrades them all to the latest version. This can obviously cause conflicts but for my use, it's working (so far) and doesn't require something drastic like deleting folders or files.
rm -rf node_modules
yarn
pod install
My Node.js app run well before. I put this Node.js app aside for several months and return back to continue to develop it on a new machine. Error happens!!!
Error information is as follows:
fs.js:27
const { Math, Object } = primordials;
^
ReferenceError: primordials is not defined
at fs.js:27:26
at req_ (/Users/xiaoningchang/Documents/Code/udfinder/avdetector/node_modules/natives/index.js:143:24)
at Object.req [as require] (/Users/xiaoningchang/Documents/Code/udfinder/avdetector/node_modules/natives/index.js:55:10)
at Object.<anonymous> (/Users/xiaoningchang/Documents/Code/udfinder/avdetector/node_modules/graceful-ncp/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
And my package.json is:
{
"name": "meminsight",
"version": "0.0.1",
"description": "JavaScript memory analyses",
"repository": {
"type": "git",
"url": "https://github.com/Samsung/meminsight.git"
},
"dependencies": {
"acorn": "3.1.0",
"argparse": "0.1.15",
"aspect-js": "^1.0.3",
"callsites": "^2.0.0",
"chai": "^4.1.2",
"codemirror": "5.1.0",
"cover": "0.2.9",
"datatables": "^1.10.18",
"ejs": "1.0.0",
"escope": "1.0.1",
"esotope": "1.4.5",
"estraverse": "4.0.0",
"execSync": "1.0.2",
"expect.js": "^0.3.1",
"express": "3.4.8",
"fast-stats": "0.0.2",
"finalhandler": "0.0.3",
"graceful-ncp": "2.0.0",
"grunt": "0.4.5",
"jquery": "2.1.3",
"jsonparse": "0.0.6",
"line-by-line": "0.1.3",
"line-reader": "^0.4.0",
"log4js": "^2.3.11",
"mkdirp": "0.5.0",
"mocha": "^1.20.1",
"multi-key-cache": "^1.0.2",
"parse5": "2.1.5",
"q": "1.2.0",
"rewriting-proxy": "0.5.1",
"rimraf": "2.2.8",
"serve-static": "^1.14.1",
"sloc": "^0.2.1",
"temp": "0.8.1",
"websocket": "^1.0.30",
"wrench": "1.5.8"
},
"scripts": {
"test": "(cat test/testSuite.txt | sed 's/^/test\\//' | xargs ./node_modules/.bin/mocha --reporter spec --harmony) && cd lifetime-analysis && ./gradlew cleanTest test && cd ..",
"build": "grunt typescript"
},
"devDependencies": {
"grunt-cli": "0.1.13",
"grunt-exec": "^0.4.6",
"grunt-simple-mocha": "0.4.0",
"grunt-typescript": "^0.8.0",
"jasmine": "^2.8.0"
},
"license": "Apache-2.0"
}
It seems that something wrong in the the dependent module natives. However, according to the package.json file, the app do not rely on natives module. In addition, there is not variable named primordials in index.js file of natives module.
Additonal information:
Version of Node.js: 12.10.0;
Version of npm: 6.11.3;
I also encounter an error that gyp ERR! build error when I npm install the app. I use the command npm audit fix to fix it. Is this related to my issue?
Could anyone help me about this issue? I am new to Node.js and have less experience to debug out of myself codes. Thanks a lot.
The natives npm package is deprecated: https://www.npmjs.com/package/natives.
If you go its page, they warn about that the package may break in future node versions -- they seriously suggest against using the package in the first place, too. I guess either a different OS or node version is the culprit here. The fact that you don't have natives listed in your package.json as dependency, means that at least one of your dependencies is using natives -or a dependency of one of your dependencies and so on...-.
One way you can check which dependencies are using natives is to run:
$ npm ls natives
I installed your dependencies in a project in my local machine -MacOS 10- and run it, and it appears that graceful-fs is using natives. graceful-fs is a dependency of graceful-ncp, which is listed in your package.json.
When I did $npm install I got several warnings, one of them about upgrading graceful-fs to version 4 to avoid future errors when upgrading node version.
The graceful-ncp package is currently on version 3.0.0, so I upgraded the version in package.json to 3.0.0. Then $ rm -rf node_modules && npm i;
After that, $ npm ls natives yields empty, which means upgrading graceful-ncp version should fix your problem - of course, you may need to add changes to your code to avoid breaking changes of graceful-ncp.
When I try running npm run build for a new webpack build I get
You have installed webpack-cli and webpack-command together. To work with the "webpack" command you need only one CLI package, please remove one of them or use them directly via their binary.
I think I installed them globally. I tried, deleting them, webpack, deleating node clearing cache but I keep getting the same result.
Using webpack 4
{
"name": "ls",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack"
},
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0"
}
}
I think the message was quite clear so just run npm uninstall "webpack-command" to remove webpack-command (b/c "webpack-cli" has newer version)