TypeError: URL不是构造函数



今天早上刚重新启动我的机器,当运行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。我已经在我的机器上安装了Node Version Manager (NVM),并运行了以下命令:

nvm use v9.5.0

现在我们又开始了!

最新更新