当我尝试使用cosmicjs提供角度6应用程序时,我收到以下错误:
Uncaught ReferenceError: process is not defined
at Object../node_modules/cosmicjs/dist/index.js (index.js:6)
at __webpack_require__ (bootstrap:81)
at Object../src/app/app.component.ts (main.js:94)
at __webpack_require__ (bootstrap:81)
at Object../src/app/app.module.ts (app.component.ts:9)
at __webpack_require__ (bootstrap:81)
at Object../src/main.ts (environment.ts:18)
at __webpack_require__ (bootstrap:81)
at Object.0 (main.ts:12)
at __webpack_require__ (bootstrap:81)
Run Code Online (Sandbox Code Playgroud)
我的最新理论与process.env属性未定义有关.
我在这里关注本教程
我的确切代码可以在这里找到
该教程似乎使用了使用.angular-cli.json而不是新的angular.json的旧版本的angular,我认为这是尝试指定环境变量的问题的一部分.
我正在使用node.js来创建一个Web应用程序.当我运行应用程序时(通过在浏览器上打开index.html或在终端上使用命令"npm start")我得到两个错误:
未捕获的ReferenceError:未定义进程
未捕获的ReferenceError:未定义require
我解决了"require is not defined"错误,具体包括在我的index.html head标签中指向此脚本的链接,其中定义了require函数.但是,我找不到类似于过程函数的东西.
我的问题是双重的:
为什么需要重新定义内置的node.js模块?为什么他们不被认可,那就是"内置模块"?术语"内置模块"是否意味着模块不需要外部/第二次重新定义?
有没有办法解决这个问题?我的脚本非常简单,我只是尝试使用node.js的基本功能,所以我无法弄清楚我可能做了什么错误.
如果有人遇到这个问题,并找到了解决问题的方法,或者出现这种情况的原因,那么你将会有很大的帮助.