Cannot find module coa/compile.js

Viewed 3600

I'm running yarn in a project created with create-react-app, but I'm getting this error:

Exit code: 1
Command: start /B node compile.js & node compile.js
Arguments: 
Directory: uber-web/node_modules/coa
Output:
/bin/sh: 1: start: not found
internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'uber-web/node_modules/coa/compile.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {

I've already uninstalled all the .lock and node_module folder, but it still doesn't work.

6 Answers

The problem is being addressed on the Github page of the coa package: https://github.com/veged/coa/issues/99

An attacker published a corrupted version of the package, do not install it especially if you are on Windows !

Update: NPM removed the malicious version and the latest version is 2.0.2 again. Everything should be back to normal.

As mentioned in the previous answer. It is due to a new release that is broken and malicious (confirmed).

As mentioned in https://github.com/veged/coa/issues/99:

Short-term fix Use "coa@2.0.2" specifically. 2.0.3. is the first update that broke things.

Additionally as @herrwitzi suggests in the comments if you use yarn you can add a resolution to your package.json

"resolutions": { "coa": "2.0.2" },

Just add above line under your dependencies in package.json.

I have met the same problem when I use "vue create hello" to build my vue project.It seems that if you use yarn to create you project,the yarn package manager will install many depandency modules,but yarn have its own default installation directory,so the dependancy modules that your project needed perhaps is not in your project directory,that is why the error "can't find module" appears.You can check it out by using "yarn global dir" in the command terminal.

To solve this problem,you can change yarn's global dir,or just using npm by default to build you project.By the way,the npm package manager have a default installation directory too,you have to note that in case meet the same problem.

Force use of v2.0.2 via resolutions in package.json: ... "resolutions": { "coa": "2.0.2" }, ... For yarn is out-of-the-box. For npm install, add to package.json:

"scripts": { "preinstall": "([ ! -f package-lock.json ] && npm install --package-lock-only --ignore-scripts --no-audit); npx npm-force-resolutions", ...

On my team, we are using a private npm registry, Verdaccio, the service got upgraded at the time coa/rc libraries were up, and our CI/CD kept failing with the compile.js error.

Somehow these versions got saved on our registry: 2.0.3, 2.0.4, 2.1.1, 2.1.3, 3.0.1, 3.1.3, prior to refreshing the instance, I tried deleting them manually with npm unpublish coa@2.x.x,

For my case, the fix mentioned "resolutions": {"coa": "2.0.2","rc": "1.2.8"} didn't solve the issue, it was until the libs were removed that it worked

I had this issue when accidentally removed the yarn.lock file. Maybe it can help someone. :)

Related