我正在构建一个带有angular2的小型web应用程序,迄今为止唯一的依赖项是导航栏的引导程序。有一天,一切工作正常(包括我可以看到我的导航栏),有一天,我在另一台机器上克隆我的回购,运行npm install
和ng serve
,添加一些组件/服务,并突然结束与该网站不加载和这在浏览器堆栈跟踪(编译没有错误成功虽然):“fs.existsSync不是一个功能”没有触及任何相关的东西
Uncaught TypeError: fs.existsSync is not a function
at devmode.js:33
at Object.<anonymous> (devmode.js:34)
at Object.__webpack_require__.constructor.oneshot.fn (devmode.js:34)
at __webpack_require__ (bootstrap 5d37cea67e603e9113e4:52)
at Object.<anonymous> (http.js:32)
at Object.<anonymous> (http.js:567)
at __webpack_require__ (bootstrap 5d37cea67e603e9113e4:52)
at Object.<anonymous> (index.js:29)
at Object.<anonymous> (index.js:255)
at __webpack_require__ (bootstrap 5d37cea67e603e9113e4:52)
at Object.171 (quote.service.ts:7)
at __webpack_require__ (bootstrap 5d37cea67e603e9113e4:52)
at Object.170 (routing.module.ts:37)
at __webpack_require__ (bootstrap 5d37cea67e603e9113e4:52)
at Object.90 (best.component.ts:8)
at __webpack_require__ (bootstrap 5d37cea67e603e9113e4:52)
at Object.168 (app.component.ts:8)
at __webpack_require__ (bootstrap 5d37cea67e603e9113e4:52)
at Object.157 (src async:7)
at __webpack_require__ (bootstrap 5d37cea67e603e9113e4:52)
at Object.342 (main.bundle.js:549)
at __webpack_require__ (bootstrap 5d37cea67e603e9113e4:52)
at webpackJsonpCallback (bootstrap 5d37cea67e603e9113e4:23)
at main.bundle.js:1
(anonymous) @ devmode.js:33
(anonymous) @ devmode.js:34
__webpack_require__.constructor.oneshot.fn @ devmode.js:34
__webpack_require__ @ bootstrap 5d37cea67e603e9113e4:52
(anonymous) @ http.js:32
(anonymous) @ http.js:567
__webpack_require__ @ bootstrap 5d37cea67e603e9113e4:52
(anonymous) @ index.js:29
(anonymous) @ index.js:255
__webpack_require__ @ bootstrap 5d37cea67e603e9113e4:52
171 @ quote.service.ts:7
__webpack_require__ @ bootstrap 5d37cea67e603e9113e4:52
170 @ routing.module.ts:37
__webpack_require__ @ bootstrap 5d37cea67e603e9113e4:52
90 @ best.component.ts:8
__webpack_require__ @ bootstrap 5d37cea67e603e9113e4:52
168 @ app.component.ts:8
__webpack_require__ @ bootstrap 5d37cea67e603e9113e4:52
157 @ src async:7
__webpack_require__ @ bootstrap 5d37cea67e603e9113e4:52
342 @ main.bundle.js:549
__webpack_require__ @ bootstrap 5d37cea67e603e9113e4:52
webpackJsonpCallback @ bootstrap 5d37cea67e603e9113e4:23
(anonymous) @ main.bundle.js:1
看到的错误一次后,我会看到它的其他机器太多,如果我推&拉,但显然没有什么内容相关的逻辑之外改变了我补充说。
到目前为止,我的研究显示了大部分与电子有关的问题,我没有使用它,或者我没有做的文件系统操作。我在这里错过了很明显的东西吗
我已经做了一些常用的解决方法,如删除node_modules &重新运行npm i
,我在npm版本5.4.0和节点8.4.0上使用当前版本的WebStorm-IDE。
问题是,当您部署到浏览器时,“fs”不存在,浏览器无法访问文件系统。你只能在节点环境中使用'fs'。 – Li357
@AndrewLi他试图通过角度CLI构建他的应用程序,所以他实际上是在一个Node环境中 –
尝试将角CLI更新到最新版本 –