【问题标题】:npm ERR! notarget No matching version found for type@modulenpm 错误! notarget 没有找到 type@module 的匹配版本
【发布时间】:2021-11-06 13:14:18
【问题描述】:

每当我使用 docker build 时都会遇到这个问题。 我在“devDependencies”中有一个带有“type”:“module”的package.json,如果删除“type”:“module”,我可以使用docker build。但是随后应用程序找不到 index.ejs 文件,所以我有点需要“type:module”来保留。有什么好主意吗?

{
    "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

【问题讨论】:

    标签: node.js docker dependencies


    【解决方案1】:

    好的,所以我找到了解决方法。

    我创建了一个可选的依赖部分并添加了“type:module”。

    之后我能够部署到 droplet。

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

    【讨论】:

      猜你喜欢
      • 2021-08-04
      • 2019-05-09
      • 2018-06-27
      • 1970-01-01
      • 2022-01-02
      • 2019-01-22
      • 2017-11-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多