添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
function done() { console.log('Now that process.stdin is paused, there is nothing more to do.'); process.exit();

Open in new window

on running node filename i get the following error :
module.js:341
    throw err;
Error: Cannot find module 'prompt'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/rohit/Checkout/codeDetect/codedetect_test.js:2:14)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)

Open in new window

So i performed npm install prompt following is the output :
├── [email protected] 
└─┬ [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ └── [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├─┬ [email protected] 
  │ │ └── [email protected] 
  │ ├── [email protected] 
  │ └─┬ [email protected] 
  │   └─┬ [email protected] 
  │     ├─┬ [email protected] 
  │     │ └── [email protected] 
  │     ├── [email protected] 
  │     ├─┬ [email protected] 
  │     │ └─┬ [email protected] 
  │     │   ├── [email protected] 
  │     │   └── [email protected] 
  │     ├── [email protected] 
  │     └── [email protected] 
  └─┬ [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    └── [email protected] 
npm WARN enoent ENOENT: no such file or directory, open '/Users/rohit/package.json'
npm WARN rohit No description
npm WARN rohit No repository field.
npm WARN rohit No README data
npm WARN rohit No license field.

Open in new window

After this the node command did work perfectly.
But i am having only the one js file in my directory and it probably installed prompt module somewhere in parent directory.
If i commit this file then if anyone who wants to use it has to say manually install all the modules with npm install.. but here as it is only one file its not that much of a problem. So i feel there should be a better way which will automatically install all the require dependencies rather than erroring out and doing npm install for each one ?
Also should i commit the node_modules folder so that user does not need to run npm install ?
Please provide some guide on how to correctly perform and run node js code.
Thanks
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Thanks that was helpful.
the command npm install <package name> --save does save the dependency info into the package.json file.
So i guess whenever a user will checkout my repo and perform npm install all the dependencies listed in package.json will be installed automatically ? and so no need to keep track of npm_modules ...
Also one thing here is that.. say my js file has 10 dependencies than in this case the first time i do need to run npm install <package-name> 10 times ? Is there any way to avoid that...