newbie warning...
I followed a good tutorial (from FreeCodeCamp) to setup a new Mean.JS stack in Cloud9. https://vimeo.com/123488494
我按照一个很好的教程(来自FreeCodeCamp)在Cloud9中设置一个新的Mean.JS堆栈。 https://vimeo.com/123488494
The tutorial says to start the application by running the command:
教程说通过运行命令来启动应用程序:
npm start
Which works just fine... except that the debugger doesn't attach and I can't use breakpoints, etc.
哪个工作得很好...除了调试器没有附加,我不能使用断点等。
What magic am I missing?
我错过了什么魔法?
1 个解决方案
#1
Figured it out on my own, sort of (no, it didn't take all 2 days). Here's the detailed "whats up" for the future newbies to stumble on this...
我自己想出来的(不,它没有花费所有2天)。这是未来新手偶然发现的详细“最新消息”......
The tutorial said to start the app with the npm command:
教程说使用npm命令启动应用程序:
npm start
For some reason not yet clear to me, npm calls the "start script" that is specified in package.json at the path... /scripts/start (and some other stuff... read the manual).
由于某些原因尚不清楚,npm调用package.json中指定的“启动脚本”路径... / scripts / start(以及其他一些东西......阅读手册)。
The default install had this in the scripts section:
默认安装在脚本部分中有此:
"scripts": {
"start": "grunt",
"test": "grunt test",
"postinstall": "bower install --config.interactive=false"
},
So...
npm start
is really just a fancy way of running...
真的只是一种奇特的运行方式......
grunt
Grunt is a "javascript task runner", which looks like it runs the javascript in gruntfile.js - also populated by the default install.
Grunt是一个“javascript任务运行器”,它看起来像是在gruntfile.js中运行javascript - 也是由默认安装填充的。
gruntfile.js has this entry:
gruntfile.js有这个条目:
nodemon: {
dev: {
script: 'server.js',
options: {
nodeArgs: ['--debug'],
ext: 'js,html',
watch: watchFiles.serverViews.concat(watchFiles.serverJS)
}
}
},
At some point, grunt is firing off the node server startup command as evidenced by the output message:
在某些时候,grunt正在触发节点服务器启动命令,如输出消息所示:
[nodemon] starting `node --debug server.js`
... But cloud9 is not respecting the --debug request for some reason... to many fancy indirections or something.
......但是由于某些原因,cloud9不尊重--debug请求......对于许多奇特的间接或某事。
So what I did was create a new cloud9 run configuration (Run (menu) > Run Configurations > New Run Configuration):
所以我所做的是创建一个新的cloud9运行配置(运行(菜单)>运行配置>新运行配置):
Name: debug
Command: server <<< this just executes server.js
Runner: Node.js
Then I can use this to debug. It does seem to be working ok, but just a few minutes into it at this point. There does seem to be a bunch of stuff that is skipped by starting the app this way... but the debugger sure does come in handy. I'll try to use this just when I want to debug.
然后我可以用它来调试。它似乎确实工作正常,但此时只需几分钟。通过这种方式启动应用程序似乎有一些东西被跳过了...但调试器肯定会派上用场。我想在调试时尝试使用它。
I love learning new technologies... just wish it was faster.
我喜欢学习新技术......希望它更快。
b.t.w. if anyone has a better solution or more experienced perspective on this, I'd be happy to mark a good response as the answer!
b.t.w.如果有人有更好的解决方案或更有经验的观点,我很乐意将答案标记为好的答案!
ON EDIT 2 hrs after posting
发布后2小时编辑
Another nice side effect of this alternate run approach is that it takes WAY less memory to run!!!! I no longer get the warning messages asking me to upgrade my precious cloud 9 free account.
这种备用运行方法的另一个好的副作用是它需要更少的内存来运行!!!!我不再收到警告消息,要求我升级我的宝贵的云9免费帐户。