0

I'm getting this output when trying to install a node application using npm install:

$ npm install
> ejs@2.7.4 postinstall /home/dh_8u42k7/quotegoodeair.com/node_modules/ejs
> node ./postinstall.js

/home/dh_8u42k7/quotegoodeair.com/node_modules/ejs/postinstall.js:9
let envDisable = isTrue(process.env.DISABLE_OPENCOLLECTIVE) || isTrue(process.
^^^
SyntaxError: Unexpected strict mode reserved word

I have already found this question which contains a workaround. However, this isn't my own code, so I can't just remove "let", it seems to be a problem with ejs itself.

For another thing, the file postinstall.js doesn't even exist, even the ejs folder doesn't exist, so I can't just go in and edit the file.

Is there something wrong with my node application, or with ejs, or maybe with npm or Node itself? Why does Node install components which aren't supported by Node? Why does Node tell me there's an error in a file which doesn't exist?

Aaron Franke
  • 3,268
  • 4
  • 31
  • 51
  • 1
    What version of node.js are you running? Is it old enough that it doesn't support ES6? – jfriend00 Dec 16 '19 at 03:00
  • "Why does Node install components which aren't supported by Node?" Yeah, well, for starters, NPM and Node are two different things. Also, there are people who run multiple versions of Node.js on the same system. And, NPM doesn't really "know" what's compatible and what isn't... that's up to the developers the module to declare it as such in package.json. – Brad Dec 16 '19 at 03:12
  • Doesn't NPM mean "Node Package Manager"? – Aaron Franke Dec 16 '19 at 04:11

1 Answers1

1

It may be that your version of node does not support the features in the application you are trying to install.

One solution may be to find out what the version of node the application that you are trying to install originally used.

I believe you can check the engine field in your package.json file.

If you local node version is different, and you need to change it, here is a link to a question providing that information: How can I specify the required Node.js version in package.json?

I also found this post interesting: https://github.com/tj/n/issues/472

It's for a different application but they received the same error message. The issue was conflicting npm folders. It's possible that the program that you are trying to install is conflicting with your existing npm setup if you have other nom folders in the directory you are installing the application in.

Ultimately, given the information you provided, I think your best bet it to look in the package.json file of the application you're trying to install and see if your local setup is conflicting with how the program is trying to be installed or run.

NeoH
  • 26
  • 4