Npm install postinstall cannot find module

4.4k Views Asked by At

I've run into an issue with running npm install. It's not finding the postinstall script and builds the path to the script duplicating the path, removing the slashes on the second half (eg: C:\User\Me\Repo\UserMeRepoScript.js). The script file does exist.

Image of problem

I have tried deleting and node-modules and package-lock. I've also tried uninstalling node.js, running npm cache clean --force then restarting, I've also made sure %appdata%\npm and %appdata%\npm-cache are deleted but still getting the same issue.

node version is 14.17.0 which is needed to run the project. with npm version 6.14.13 8.5.5


Update 22/3

The issue remains but I can get NPM to run and install in powershell. I'm now facing a new issue where the conmmand twilio flex:plugins:build is erroring out with seeming the same issue surrounding missing slashes. Unfortunately this time it's also showing the same issue in powershell.

new issue

2

There are 2 best solutions below

2
On

I think that the error you are getting now isn't to do with removing slashes. While there are no slashes in the file paths in the output, I think that is a display thing rather than an issue in the actual running of the program.

Instead, what the new error message is saying is that you are missing a dependency (@babel/plugin-proposal-private-property-in-object to be precise). This module is down the dependency tree of @twilio/flex-plugin-scripts, so perhaps hasn't installed correctly. I would recommend that you remove your node_modules directory and perform npm install again, to give you a clean install of dependencies. Then try building the plugin again.

1
On

I had a similar error that led me to this post (keyword 'postinstall'), so I thought I share my work around. But to explain, my error has something to do with nodejs and wsl not syncing, thus creating some dependency errors during builds as they are in different environments. You could fix this, by (but honestly I think it's a big hassle, you should just wait for their official release - if there's any):

To save myself from potentially balding, you could try docker. Or if docker is not your style, you can use a popular node version manager called NVM. Uninstall your windows node, and move things to your WSL instead.