简体   繁体   中英

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

I get this issue whenever I use docker build. I have a package.json with "type": "module" in "devDependencies" and if remove "type": "module", I can use docker build. But then the app cannot find the index.ejs file, so I kinda need the "type:module" to stay. 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.

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

This is just non-sense: type isn't the name of a package, and module isn't a valid version. None of this goes in the dependency sections; "type": "module" should be at the top-level in package.json.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM