package.json 文件在錯誤的文件夾中創建 (package.json file created in the wrong folder)


問題描述

package.json 文件在錯誤的文件夾中創建 (package.json file created in the wrong folder)

我正在創建一個應用程序來使用無服務器的 API,並且初始安裝沒問題。npm serverless install 的文件夾之一是 auth‑server,其中有兩個文件 ‑ handler.jsserverless.yml 被創建(除了 .gitignore)。

幾步之後,我必須安裝 Axios,因為我需要創建一個 POST 請求 API。在 auth‑server 目錄中,我運行了通常的 npm 語法來安裝 Axios,npm install axios。然而,令我驚訝的是,npm 並沒有在 auth‑server 中創建 package.json(和 package‑lock.json)文件 文件夾,但使用了根文件。

我試圖環顧四周,看看問題是否反復出現,但一無所獲。我知道 package‑json 文件是在執行 npm 的目錄文件夾中創建的,因為我已經使用過 axios 幾次。有人可以指出問題可能出在哪裡嗎?提前致謝。


參考解法

方法 1:

In case someone else needs this: I found out that although not in all cases, it is not uncommon that the npm will use the package.json file of the root folder. As I needed it inside the auth‑server folder, I simply created another package.json file inside it (with a pair of curly brackets on it to avoid a parse error code EJSONPARSE) and saved it. Once I installed Axios one more (npm install axios) the package.json file began to be used and added Axios as a dependency.

(by cgobbetcgobbet)

參考文件

  1. package.json file created in the wrong folder (CC BY‑SA 2.5/3.0/4.0)

#Axios #serverless #npm #terminal






相關問題

如何從 Contentful 中獲取單個條目並按字段值查詢? (How to fetch a single entry from Contentful and query by field value?)

VUE 中的 Axios 承諾失敗,無法讀取未定義的屬性“toUpperCase” (Axios promise in VUE failed with Cannot read property 'toUpperCase' of undefined)

Symfony 4 - 使用 Axios 提交表單? (Symfony 4 - Submit form with Axios?)

Laravel:帶有axios的表單不保存 (Laravel: form with axios not saving)

使用 axios 將用戶圖像上傳到strapi (uploading user image to strapi using axios)

我的 module.exports 返回為 [object Object] (My module.exports return as [object Object])

即使驗證要求無效,數據仍在發送,解決此問題的最佳方法是什麼? (Data is sending even if validation requirements are not valid, whats the best way to approach this?)

如何等到使用 Axios 上傳文件 (How to wait until file is uploaded using Axios)

axios 請求錯誤:使用 Heroku 的 ECONNREFUSED (axios request Error: ECONNREFUSED with Heroku)

為什麼我的 axios 調用即使在解決之後仍返回 undefined? (Why does my axios call return undefined even after then is resolved?)

為什麼在使用 axios.post 時我的頁面上有一個 OBJECT PROMISE (Why i have a OBJECT PROMISE on my page when using axios.post)

如何在使用反應測試庫單擊父組件上的按鈕後測試子組件呈現文本? (How to test the child component render text after the button on the parent component click with react testing library?)







留言討論