简体   繁体   中英

Ionic Serve error with module.js

My app is working on my macbook air, I cloned the app and tried to run it on my iMac using ionic serve, I am getting this error.

I have tried using different versions of node and looking online for solutions.

ionic $ module.js:338
    throw err;
          ^
Error: Cannot find module 'escape-string-regexp'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/kel/Documents/Code/gogenieapp-genie-side/node_modules/chalk/index.js:2:26)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)

The problem is probably about the dependencies. Check your "package.json" file on the project that is working and also the versions of the libraries/dependencies that are installed on this project.

If there is an update on some libraries and your code on the "package.json" file is like:

"dependencies": {
  ...
  "library": "^3.9.0",
  ...
}

then in your new project the latest version of those libraries will be installed. Had the same problem.

Just go to your "package.json" file of the new project and change the code to:

"dependencies": {
  ...
  "library": "3.9.0",
  ...
}

so that, the exact version of the library will be installed. This solved for me due to the updated API of a library.

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