![](/img/trans.png)
[英]npm ERR! Invalid package name - When deploying Nuxt3 project in firebase hosting
[英]npm ERR! Invalid version: "1"
問題:
在我的本地機器上執行“節點應用程序”時,一切正常。
但是當我將我的項目部署到 Google App Engine 時,該實例被終止並且我在我的日志中發現以下錯誤:
npm ERR! Invalid version: "1"
我在看:
我需要糾正的錯誤是什么?
gcloud app deploy --version=deploy
啟動的部署過程
總是以:
ERROR: (gcloud.app.deploy) Error Response: [4] Timed out waiting for the app infrastructure to become healthy.
這是我的 package.json
代碼:
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"
}
}
在我的情況下是
"version": "1"
我已經編輯為
"version": "1.0.0"
它修復了。
在 package.json 中,'engine' 屬性允許您阻止在不受支持的 CLI 工具版本上運行的 node.js 應用程序。
您可以刪除或修改這些值。 通過快速查看 gcloud 文檔,他們使用的是 node.js (v9.4.0) 的最新穩定版,它與 npm v5.6.0 捆綁在一起。 您可以通過在版本前添加大於字符來允許您的應用程序在現有版本和更高版本上運行。
"engines": {
"node": ">6.9.4",
"npm": ">4.2.0"
},
package.json -> 版本語義可能需要像 1.0.0
根據此處為node-semver提供的文檔,加載的依賴包版本可能存在問題
仔細檢查這些版本或刪除所有這些然后嘗試,如果它有效然后繼續一個一個添加,最終當它停止工作時你知道哪個版本編號有問題
以下列表可能是可能的嫌疑人
"body-parser": "1.1*.1",
"fs": "0.0.1-security"
嘗試用*
替換所有依賴版本,與 npm 版本相同。 然后運行npm install
。 我不確定它是否會起作用,但請嘗試一下。
為我修復的是刪除 node_modules 和 package-lock.json 並重新安裝npm install
請刪除 package-lock.json 文件。 這將解決一個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.