簡體   English   中英

為什么npm start在node.js中給出錯誤?

[英]Why does npm start give error in node.js?

每次我嘗試為create-react-app運行npm start時,都會出現此錯誤。 我已經卸載了node.js,重新安裝了它,並做了我能想到的一切,但是我似乎無法修復。 這是我的錯誤:

> react-scripts start

/Users/Eduardo/my-app/node_modules/ajv/lib/keyword.js:65
      throw new Error('custom keyword definition is invalid: '  + this.errorsText(validateDefinition.errors));
      ^

Error: custom keyword definition is invalid: data.errors should be boolean
    at Ajv.addKeyword (/Users/Eduardo/my-app/node_modules/ajv/lib/keyword.js:65:13)
    at module.exports (/Users/Eduardo/my-app/node_modules/ajv-errors/index.js:10:7)
    at Object.<anonymous> (/Users/Eduardo/my-app/node_modules/schema-utils/src/validateOptions.js:22:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Eduardo/.npm/_logs/2019-02-10T01_38_44_462Z-debug.log

要啟動React,您需要:

  1. 單擊此處以在新選項卡中導航到Node.js主頁。
  2. 您應該會看到下載Node.js的鏈接。 單擊您選擇的下載鏈接。 按照后續說明安裝Node.js和npm。 如果您已經安裝了Node.js,那就可以了。

  3. 新建一個文件夾

  4. 在那里打開nodejs終端
  5. 使npm init react-app .
  6. 使npm start

有關在此處設置React應用的更多詳細信息

今天出事了。 我已經開發了React應用一段時間了。 舊的... npm create-react-app,您對npm init react-app的建議。 或者,npm init react-app my-app。 無論我如何嘗試,都會遇到上述錯誤。 我的npm是6.7.0,節點是8.11.1。

我不確定,但是有些不對。

這是我所做的(破解)操作,但是我強烈建議由負責此庫的人員修復此問題。

在節點模塊中(通過create-react-app應用程序名稱或npm init react-app應用程序名稱或npx create-react-app應用程序名稱...生成)中的任何一個...目錄node = modules / avj / lib / keywords.js ...並轉到具有以下內容的第65行:

如果(!validateDefinition(definition))拋出新錯誤('自定義關鍵字定義無效:'+ this.errorsText(validateDefinition.errors));

注釋為:

//  if (!validateDefinition(definition))
   //   throw new Error('custom keyword definition is invalid: '  + 
   // this.errorsText(validateDefinition.errors));

保存...並返回目錄並>> npm start

注意:這是一個hack,我不知道長期影響是什么。 另外,如果您對其進行黑客攻擊,則...如果您嘗試將應用程序部署在將從package.json文件生成的雲中(例如Heroku),它將重新創建這些行,並且該應用程序將無法在雲中啟動。 因此,除非您只是想克服愚蠢的錯誤,否則不建議這樣做。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM