Error: Cannot find module '../lib/utils/unsupported.js' while using Ionic

后端 未结 18 2876
悲哀的现实
悲哀的现实 2020-12-12 09:34

I always get this error message when I run \"Ionic start project name\":

Error message

Running command - failed![ERROR] An error occurred while run         


        
相关标签:
18条回答
  • 2020-12-12 10:26

    The error Cannot find module '../lib/utils/unsupported.js' is caused by require('../lib/utils/unsupported.js') in ./lib/node_modules/npm/bin/npm-cli.js.

    According to the nodejs require docs, the required module is searched relative to the file, as it starts with ../.

    Thus, if we take the relative path ../lib/utils/unsupported.js starting from ./lib/node_modules/npm/bin/npm-cli.js, the required module must reside in ./lib/node_modules/npm/lib/utils/unsupported.js. If it is not there, I see two options:

    • the installation is corrupt, in which case Vincent Ducastel's answer to reinstall node might work
    • npm is no symlink to ./lib/node_modules/npm/bin/npm-cli.js. This is what caused the error in my setup. If you call npm, it will typically find it be searching it in the directories listed in the PATH env var. It might for example be located in ./bin. However, npm in a ./bin directory should only be a symlink to the aforementioned ./lib/node_modules/npm/bin/npm-cli.js. If it is not a symlink but directly contains the code, somewhere in the installation process the symlink got replaced by the file it links to. In this case, it should be sufficient to recreate the symlink: cd ./bin; rm npm; ln -s ../lib/node_modules/npm/bin/npm-cli.js npm (update: command fixed, thx @massimo)

    All answers that suggest to check the NODE_PATH or the npmrc config should be ignored, as these are not considered when searching modules relatively.

    0 讨论(0)
  • 2020-12-12 10:28

    I got this error by mixing install/update methods: installed node via downloading package from website and later I used brew to update.

    I fixed by uninstalling the brew version :

    brew uninstall --ignore-dependencies node

    Then I went back to node website and downloaded and installed via the package manager: https://nodejs.org/en/download/ For some reason, no amount of trying to reinstall via brew worked.

    0 讨论(0)
  • 2020-12-12 10:31

    Tried all above/older brew installation answers, none is working for my laptop.

    Only below method could fix my issue.

    1) Run following commands:

    sudo rm -rf /usr/local/lib/node_modules/npm
    brew uninstall --force node      
    

    2) Then, proceed to Node.js Official Website https://nodejs.org/en/download/current/ to download latest package for new installation.

    3) Run your npm command again, which should longer have any errors.

    This method is working on macOS Mojave Version 10.14.4.

    0 讨论(0)
  • 2020-12-12 10:32

    https://nodejs.org/en/

    Simply download node from the official website, this worked for me! :)

    0 讨论(0)
  • 2020-12-12 10:33

    Simply follow three steps;

    1. Clear npm cache forcefully:

      npm cache clean -f

    2. Install n package globally using npm:

      npm install -g n

    3. Install from any of three options:

      a. sudo n stable (get the stable version)

      b. sudo n latest (get the latest version of node)

      c. sudo n x.x.x (get the specific version of node)

    0 讨论(0)
  • 2020-12-12 10:34

    I followed the previous answers and reinstalled node. But I got this error.

    Warning: The post-install step did not complete successfully You can try again using brew postinstall node

    So I ran this command

    sudo chown -R $(whoami):admin /usr/local/lib/node_modules/
    

    Then ran

    brew postinstall node
    
    0 讨论(0)
提交回复
热议问题