我写了我的第一个node.js应用程序,但它找不到快递库:
C:\ChatServer\Server>node server.js
module.js:340
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\ChatServer\Server\server.js:6:9)
at Object.<anonymous> (C:\ChatServer\Server\server.js:25:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Run Code Online (Sandbox Code Playgroud)
但快递被挂了(带-g钥匙):
C:\ChatServer\Server>npm install -g express
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/connect/2.7.11
npm http GET https://registry.npmjs.org/commander/0.6.1
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/mkdirp/0.3.4
npm http GET https://registry.npmjs.org/cookie/0.1.0
npm http GET …Run Code Online (Sandbox Code Playgroud) 我已经使用此帖子中的说明为node.js安装了NVM:
http://www.backdrifter.com/2011/02/18/using-nvm-and-npm-to-manage-node-js/
当我在节点版本之间切换然后使用npm来安装模块时,所有模块都放在同一个'node_modules'文件夹(〜/ node_modules /)中,而不是放在特定于该节点版本的'node_modules'目录中?
关于如何解决这个问题的任何想法?
当我试图运行nodeJS文件时,我的Ubuntu机器出现以下错误
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'mkdirp'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/home//dev/ation/siya/common.js:7:19)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
Run Code Online (Sandbox Code Playgroud)
所以我试过 npm install mkdirp
npm http GET https://registry.npmjs.org/mkdirp
npm ERR! Error: failed to fetch from registry: mkdirp
npm ERR! at /home/local/lib/node_modules/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR! at cb (/home/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR! at Request._callback (/home/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:136:18) …Run Code Online (Sandbox Code Playgroud) 我有一个 API,它发送具有以下标头的响应:
Headers(8)
Test Results(1/1)
Status:200 OK
Time:5890 ms
Size:1.24 MB
Access-Control-Allow-Origin ?*
Cache-Control ?no-cache
Content-Disposition ?attachment; filename=Report.csv
Content-Length ?1298149
Content-Type ?text/csv
Date ?Fri, 22 Jun 2018 08:50:05 GMT
Expires ?-1
Pragma ?no-cache
Run Code Online (Sandbox Code Playgroud)
我想下载附件文件'Report.Csv'
谁能建议我如何通过脚本或纽曼做到这一点