search

Home  >  Q&A  >  body text

node.js - nodejs项目换了环境后各种报错

nodejs项目从一个mac换到另一个mac后各种报错

/Users/test/WebstormProjects/testtt/node_modules/node-readability/node_modules/jsdom/lib/jsdom.js:3
`jsdom 4.x onward only works on io.js or Node.js 4 or newer: https://github.co
^
[SyntaxError: Unexpected token ILLEGAL]
SyntaxError: Unexpected token ILLEGAL

at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/test/WebstormProjects/testtt/node_modules/node-readability/src/readability.js:1:75)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/test/WebstormProjects/testtt/api/services/readabilityService.js:5:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
天蓬老师天蓬老师2847 days ago584

reply all(6)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:50:50

    Because your node version is too low,
    jsdom 4.x onward only works on io.js or Node.js 4 or newer

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 13:50:50

    Check the node version difference between your two macs. It seems that your node version is too low.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 13:50:50

    Thanks for the invitation. As mentioned above, the version is low~just download the latest version~

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:50:50

    node -v checks node version

    You can install node version management tools such as nvm or n on mac

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:50:50

    According to my understanding, this kind of node project not only needs to indicate the version of the dependent package, but also needs to indicate the version of other dependencies, such as the running environment version number and the build tool version number, operating system, database version, etc. , because the node changes too fast

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:50:50

    node version problem

    Also develop a good habit. Every time you install a new dependent module during the project life cycle, npm install xxx --save
    npm adds --save. The version information of the dependent module will be written to package.json.
    In this way, every time you change the server deployment, you can directly cp the package file and execute npm install, and you can deploy it according to the information (restore) in package.json and rely on the running environment

    Of course the most important thing is node version compatibility.

    reply
    0
  • Cancelreply