【问题标题】:TypeError: URL is not a constructor - react-dev-utils/getPublicUrlOrPath.jsTypeError:URL 不是构造函数 - react-dev-utils/getPublicUrlOrPath.js
【发布时间】:2021-01-29 12:42:43
【问题描述】:

今天早上刚重新启动我的机器,并在运行 react-scripts start 以使我的反应站点在本地运行时醒来。

/blah/blah/node_modules/react-dev-utils/getPublicUrlOrPath.js:52
    const validHomepagePathname = new URL(homepage, stubDomain).pathname;
                                  ^

TypeError: URL is not a constructor
    at getPublicUrlOrPath (/blah/blah/node_modules/react-dev-utils/getPublicUrlOrPath.js:52:35)
    at Object.<anonymous> (/blah/blah/node_modules/react-scripts/config/paths.js:26:25)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/blah/blah/node_modules/react-scripts/config/env.js:13:15) 
npm ERR! code ELIFECYCLE 
npm ERR! errno 1 
npm ERR! blah@0.1.0 start: `react-scripts start` 
npm ERR! Exit status 1 npm ERR!  
npm ERR! Failed at the blah@0.1.0 start script. 
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

昨晚还可以,但是我重启了机器,早上还是不行。

提前谢谢你!

【问题讨论】:

    标签: node.js reactjs npm terminal


    【解决方案1】:

    误报。以防万一其他人遇到这种情况,您可能使用的是旧版本的 Node.js。我已经在我的机器上安装了 Node Version Manager (NVM) 并运行了以下命令:

    nvm use v9.5.0
    

    现在我们又开始营业了!

    【讨论】:

      猜你喜欢
      • 2021-08-14
      • 1970-01-01
      • 1970-01-01
      • 2020-02-19
      • 2017-01-16
      • 2018-04-27
      • 1970-01-01
      • 1970-01-01
      • 2019-04-05
      相关资源
      最近更新 更多