Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js npm安装后,npm缺少软件包_Node.js_Npm_Npm Install_Node Modules_Yarnpkg - Fatal编程技术网

Node.js npm安装后,npm缺少软件包

Node.js npm安装后,npm缺少软件包,node.js,npm,npm-install,node-modules,yarnpkg,Node.js,Npm,Npm Install,Node Modules,Yarnpkg,我决定在远程机器上部署我的软件,但当我开始“npm安装”以添加package.json的每个包时,不可能添加“supertest”包。我尝试了很多方法来解决这个问题,删除node_模块并重新启动npm安装两次,或者使用thread代替npm $ npm install supertest + supertest@2.0.1 removed 13 packages and updated 3 packages in 2.28s api-http@remotemachine:~/api-http$

我决定在远程机器上部署我的软件,但当我开始“npm安装”以添加package.json的每个包时,不可能添加“supertest”包。我尝试了很多方法来解决这个问题,删除node_模块并重新启动npm安装两次,或者使用thread代替npm

$ npm install supertest
+ supertest@2.0.1
removed 13 packages and updated 3 packages in 2.28s
api-http@remotemachine:~/api-http$ npm test

> api-http@0.0.1 test /home/api-http/api-http
> NODE_ENV=test mocha --recursive test

module.js:487
    throw err;
    ^

Error: Cannot find module 'supertest'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/api-http/api-http/test/app/controllers/crop.js:3:17)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at /home/api-http/api-http/node_modules/mocha/lib/mocha.js:230:27
    at Array.forEach (native)
    at Mocha.loadFiles (/home/api-http/api-http/node_modules/mocha/lib/mocha.js:227:14)
    at Mocha.run (/home/api-http/api-http/node_modules/mocha/lib/mocha.js:513:10)
    at Object.<anonymous> (/home/api-http/api-http/node_modules/mocha/bin/_mocha:480:18)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
npm ERR! Test failed.  See above for more details.

Supertest
位于
devDependencies
中,如果运行带有标志
--production
NODE_ENV
npm install
将不会安装。您可以将其移动到
依赖项
或更改
节点_ENV
。您可以在

中找到有关它的更多信息。您是否尝试过
npm安装-g supertest
?您是否在远程计算机上设置了环境变量
NODE_ENV
supertest
是包.json中的s dev dependency i。因此,如果将
NODE\u ENV
设置为
'production'
也尝试
npm install--only=dev
{
  "name": "api-http",
  "version": "0.0.1",
  "private": true,
  "main": "app.js",
  "scripts": {
    "start": "node app.js",
    "test": "NODE_ENV=test mocha --recursive test",
    "test:coverage": "nyc npm test",
    "test:unit": "mocha --recursive test/middleware test/models test/routes",
    "test:integration": "mocha --recursive test/integration"
  },
  "dependencies": {
    "async": "^2.5.0",
    "body-parser": "^1.13.3",
    "chai-http": "^3.0.0",
    "compression": "^1.7.0",
    "cookie-parser": "^1.3.3",
    "cors": "^2.8.4",
    "d3": "^4.10.0",
    "express": "^4.13.3",
    "glob": "^6.0.4",
    "http-status": "^1.0.1",
    "jade": "^1.11.0",
    "lodash": "^4.17.4",
    "method-override": "^2.3.0",
    "mocha": "^3.5.0",
    "morgan": "^1.6.1",
    "mysql": "^2.14.1",
    "only": "0.0.2",
    "request": "^2.81.0",
    "sequelize": "^3.5.1",
    "serve-favicon": "^2.3.0",
    "shuffle-array": "^1.0.1",
    "terraformer": "^1.0.8"
  },
  "devDependencies": {
    "chai": "^3.5.0",
    "debug": "^2.6.8",
    "grunt": "^1.0.1",
    "grunt-contrib-watch": "^1.0.0",
    "grunt-develop": "^0.4.0",
    "load-grunt-tasks": "^3.2.0",
    "nyc": "^10.0.0",
    "supertest": "^2.0.1",
    "time-grunt": "^1.2.1"
  }
}