npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.44k stars 3.14k forks source link

[BUG] npm install --only=dev leakly install package #2471

Closed suntopo closed 3 years ago

suntopo commented 3 years ago

Current Behavior:

i wanna to install devdependecies only as basic docker build image, but it doesn`t work as expect. Step 1. package.json

  "dependencies": {
    "alidayu": "0.0.1",
    "alidayu-es6": "0.0.1",
    "alidayu-node": "1.0.3",
    "alidayujs": "1.0.5",
    "amqplib": "0.5.1",
    "axios": "0.13.1",
    "bcryptjs": "2.3.0",
    "bunyan": "1.8.1",
    "co": "4.6.0",
    "co-busboy": "1.3.1",
    "co-redis": "2.1.0",
    "co-request": "1.0.0",
    "cron": "1.2.1",
    "joi": "8.4.2",
    "jsonwebtoken": "7.0.1",
    "keygrip": "1.0.1",
    "koa": "1.2.0",
    "koa-bodyparser": "2.2.0",
    "koa-compress": "1.0.9",
    "koa-csrf": "2.5.0",
    "koa-favicon": "1.2.1",
    "koa-generic-session": "1.11.1",
    "koa-helmet": "1.0.0",
    "koa-jwt": "1.2.0",
    "koa-logger": "1.3.0",
    "koa-ratelimit": "2.3.0",
    "koa-redis": "2.1.1",
    "koa-router": "5.4.0",
    "koa-send": "3.2.0",
    "koa-session": "3.3.1",
    "koa-static": "2.0.0",
    "koa-views": "4.1.0",
    "lodash": "4.14.1",
    "moment": "2.20.1",
    "mysql": "2.11.1",
    "node-xlsx": "0.15.0",
    "nodemailer": "3.1.0",
    "nodemailer-smtp-transport": "2.7.2",
    "redis": "2.6.2",
    "request": "2.83.0",
    "sequelize": "3.23.4",
    "thunkify-wrap": "1.0.4",
    "underscore": "1.8.3",
    "urlencode": "1.1.0",
    "winston": "2.2.0"
  },
  "devDependencies": {
    "@babel/cli": "^7.11.6",
    "@babel/core": "^7.11.6",
    "@babel/plugin-proposal-class-properties": "^7.10.4",
    "@babel/preset-env": "^7.11.5"
  }

Step2. remove package-lock.json, node_modules

rm package-lock.json
rm -rf node_modules

Step3. npm install --only=dev

npm install --only=dev
npm WARN deprecated joi@8.4.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated nodemailer@3.1.0: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
npm WARN deprecated request@2.83.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated sequelize@3.23.4: This version will no longer receive security fixes per our security policy. Please update to sequelize@5 or above.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated topo@2.0.2: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated joi@6.10.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated har-validator@5.0.3: this
npm WARN deprecated hawk@6.0.2: This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated har-validator@5.1.5: this
npm WARN deprecated hoek@2.16.3: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated topo@1.1.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated boom@4.3.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated cryptiles@3.1.4: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated sntp@2.1.0: This module moved to @hapi/sntp. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated boom@5.2.0: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN notsup Unsupported engine for amqplib@0.5.1: wanted: {"node":">=0.8 <6 || ^6"} (current: {"node":"12.16.3","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: amqplib@0.5.1
npm WARN zerobuy-lite@0.0.1 No description
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 291 packages from 144 contributors in 13.641s

Step4. npm run build build - "build": "rm -rf build && npx babel ./ --out-dir build"

Error: Cannot find module 'minimatch'
Require stack:
- /home/suntopo/Downloads/backend/node_modules/@babel/cli/node_modules/glob/glob.js
- /home/suntopo/Downloads/backend/node_modules/@babel/cli/lib/babel/options.js
- /home/suntopo/Downloads/backend/node_modules/@babel/cli/lib/babel/index.js
- /home/suntopo/Downloads/backend/node_modules/@babel/cli/bin/babel.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/home/suntopo/Downloads/backend/node_modules/@babel/cli/node_modules/glob/glob.js:45:17)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/suntopo/Downloads/backend/node_modules/@babel/cli/node_modules/glob/glob.js',
    '/home/suntopo/Downloads/backend/node_modules/@babel/cli/lib/babel/options.js',
    '/home/suntopo/Downloads/backend/node_modules/@babel/cli/lib/babel/index.js',
    '/home/suntopo/Downloads/backend/node_modules/@babel/cli/bin/babel.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! zerobuy-lite@0.0.1 build: `rm -rf build && babel ./ --out-dir build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the zerobuy-lite@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/suntopo/.npm/_logs/2021-01-11T04_07_42_433Z-debug.log

BUT Step 5. clear denpencies in package.json

 "dependencies": {
  },
  "devDependencies": {
    "@babel/cli": "^7.11.6",
    "@babel/core": "^7.11.6",
    "@babel/plugin-proposal-class-properties": "^7.10.4",
    "@babel/preset-env": "^7.11.5"
  }

Step6. repeat step 2 3 4

> rm -rf build && npx babel ./ --out-dir build

Successfully compiled 126 files with Babel (2566ms).

Expected Behavior:

it should success at step 4

Steps To Reproduce:

step 1-6

Environment:

darcyclarke commented 3 years ago

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo