Node 與工具鏈

Node.js、npm、模組安裝與命令列環境。

15 / 15 題 · 依票數排序

3.4k

Using async/await with a forEach loop

Are there any issues with using async / await in a forEach loop? I'm trying to loop through an array of files and await on the contents of each file. import fs from 'fs-promise' a…

2016javascriptnode.jspromiseasync-awaitecmascript-2017·3 重點答案·2.5M 次瀏覽
2.2k

How to decide when to use Node.js?

I am new to this kind of stuff, but lately I've been hearing a lot about how good Node.js is. Considering how much I love working with jQuery and JavaScript in general, I can't he…

2011javascriptnode.jsweb-applications·3 重點答案·590k 次瀏覽
2.1k

Writing to files in Node.js

I've been trying to find a way to write to a file when using Node.js, but with no success. How can I do that?

2010javascriptnode.jsfileexpressfs·3 重點答案·2.2M 次瀏覽
2.1k

Turning off an ESLint rule for a specific line

In order to turn off a linting rule for a particular line in JSHint, we use the following rule: /* jshint ignore:start*/ $scope.someVar = ConstructorFunction(); /* jshint ignore:e…

2015javascriptjshinteslint·3 重點答案·1.9M 次瀏覽
1.9k

What is the difference between Bower and npm?

What is the fundamental difference between bower and npm ? Just want something plain and simple. I've seen some of my colleagues use bower and npm interchangeably in their project…

2013javascriptnpmbowerdependency-management·3 重點答案·340k 次瀏覽
1.9k

'map' function for objects (instead of arrays)

I have an object: myObject = { 'a': 1, 'b': 2, 'c': 3 } I am looking for a native method, similar to Array.prototype.map that would be used as follows: newObject = myObject.map(fu…

2013javascriptnode.jsfunctional-programmingmap-function·3 重點答案·3M 次瀏覽
1.7k

How do I debug Node.js applications?

How do I debug a Node.js server application? Right now I'm mostly using alert debugging with print statements like this: sys.puts(sys.inspect(someVariable)); There must be a bette…

2009javascriptnode.jsdebugginggoogle-chrome-devtools·3 重點答案·569k 次瀏覽
1.6k

Read environment variables in Node.js

Is there a way to read environment variables in Node.js code? Like for example Python's os.environ['HOME'] .

2011javascriptnode.jsenvironment-variables·3 重點答案·993k 次瀏覽
1.6k

Where does npm install packages?

Can someone tell me where can I find the Node.js modules, which I installed using npm ?

2011javascriptnode.jslocationnpm·3 重點答案·1.4M 次瀏覽
1.5k

Sending command line arguments to npm script

The scripts portion of my package.json currently looks like this: "scripts": { "start": "node ./script.js server" } ...which means I can run npm start to start the server. So far…

2012javascriptnode.jsnpm·3 重點答案·1.2M 次瀏覽