简体   繁体   English

npm 错误! notarget 找不到与 type@module 匹配的版本

[英]npm ERR! notarget No matching version found for type@module

I get this issue whenever I use docker build.每当我使用 docker 构建时,我都会遇到这个问题。 I have a package.json with "type": "module" in "devDependencies" and if remove "type": "module", I can use docker build.我有一个 package.json,在“devDependencies”中带有“type”:“module”,如果删除“type”:“module”,我可以使用 docker 构建。 But then the app cannot find the index.ejs file, so I kinda need the "type:module" to stay.但是应用程序找不到 index.ejs 文件,所以我有点需要保留“type:module”。 Any good ideas?有什么好主意吗?

{
    "name": "mediasoup-custom",
    "version": "1.0.0",
    "description": "",
    "main": "app.js",
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node src/app.js",
    "mon": "nodemon src/app.js",
    "watch": "watchify public/index.js -o public/bundle.js -v",
    "type": "module"
     },
     "author": "",
     "license": "ISC",
    "dependencies": {
    "body-parser": "^1.19.0",
    "ejs": "^3.1.6",
    "express": "^4.17.1",
    "httpolyglot": "^0.1.2",
    "mediasoup": "^3.7.1",
    "mediasoup-client": "^3.6.37",
    "mongoose": "^5.12.10",
    "protoo-client": "^4.0.4",
    "protoo-server": "^4.0.4",
    "react": "^17.0.2",
    "request": "^2.88.2",
    "socket.io": "^2.3.0"
    
     },
    "devDependencies": {
    "@babel/cli": "^7.14.3",
    "@babel/core": "^7.14.3",
    "type": "module"
      },
      "engines": {
      "node": "12.19.0"
  }
}

 > [ 6/10] RUN npm install:
 #11 1.042 npm WARN read-shrinkwrap This version of npm is compatible with 
 lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll 
 try to do my best with it!
 #11 2.810 npm ERR! code ETARGET
 #11 2.817 npm ERR! notarget No matching version found for type@module.
 #11 2.818 npm ERR! notarget In most cases you or one of your dependencies are 
 requesting
 #11 2.818 npm ERR! notarget a package version that doesn't exist.
 #11 2.818 npm ERR! notarget 
 #11 2.818 npm ERR! notarget It was specified as a dependency of 'app'
 #11 2.818 npm ERR! notarget 
 #11 2.826 
 #11 2.826 npm ERR! A complete log of this run can be found in:
 #11 2.826 npm ERR!     /root/.npm/_logs/2021-09-09T22_41_21_395Z-debug.log
 ------
 executor failed running [/bin/sh -c npm install]: exit code: 1

OK so i found a fix.好的,所以我找到了解决办法。

I created a optional dependancy section and added the "type:module".我创建了一个可选的依赖部分并添加了“类型:模块”。

Afterwards I was able to deploy to droplet.之后我能够部署到 Droplet。

"optionalDependencies": {
"type": "module"
},

This is just non-sense: type isn't the name of a package, and module isn't a valid version.这简直是胡说八道: type不是 package 的名称, module不是有效版本。 None of this goes in the dependency sections;这些都不在依赖部分; "type": "module" should be at the top-level in package.json. "type": "module"应该在 package.json 中的顶层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NPM 找不到 type@module 的匹配版本 - NPM no matching version found for type@module npm err notarget找不到bootstrap @ 3的匹配版本 - npm err notarget no matching version found for bootstrap@3 npm ERR! notarget找不到与lodash@4.17.12-pre匹配的版本 - npm ERR! notarget No matching version found for lodash@4.17.12-pre 安装包时卡住。 npm 错误。 notarget 找不到与 sockjs-client@0.0.0-unreleasable 匹配的版本 - stuck while installing packages. npm ERR! notarget No matching version found for sockjs-client@0.0.0-unreleasable npm 错误。 notarget 找不到与@typescript-eslint/parser@5.4.0 匹配的版本 - npm ERR! notarget No matching version found for @typescript-eslint/parser@5.4.0 创建反应应用程序:npm 错误。 notarget 未找到与 toidentifier@1.0.1 匹配的版本 - create-react-app : npm ERR! notarget No matching version found for toidentifier@1.0.1 呃! notarget 没有为 elements@~0.1.2 找到匹配的版本 - ERR! notarget No matching version found for elements@~0.1.2 nodejs: UNMET DEPENDENCY type@module / 我怎样才能让 `npm list` 停止返回这个错误? - nodejs: UNMET DEPENDENCY type@module / How can I get `npm list` stop returning this error? npm ERR:无效版本:“1” - npm ERR! Invalid version: "1" 无法修改和测试分叉的GitHub库-npm ERR! 找不到版本 - Unable to modify and test a forked GitHub library - npm ERR! version not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM