npm install error ENOTDIR

前端 未结 4 2146
误落风尘
误落风尘 2020-12-15 21:55

I am very new to Node.js and trying to install Flatiron using npm but it gives me an error.

sudo npm install flatiron -g

And I get -

4条回答
  •  轮回少年
    2020-12-15 22:41

    Below are the steps to install a given release from source without root NOTE - this installs nodejs which gives you both node as well as npm, they come together per release.

    to start fresh remove prior node.js and npm installs as well as these :

    sudo mv ~/.npmrc ~/.npmrc_ignore
    sudo mv ~/.npm   ~/.npm_ignore
    sudo mv ~/tmp    ~/tmp_ignore
    sudo mv ~/.npm-init.js ~/.npm-init.js_ignore
    

    to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :

    export NODE_PARENT=${HOME}/bin_0_10_32
    
    mkdir ${NODE_PARENT}
    

    download source from : http://nodejs.org/download/

    cd node-v0.xxxx
    
    ./configure   --prefix=${NODE_PARENT}/nodejs
    
    make -j8
    make install   #  IMPORTANT this is NOT using sudo
                   # not wanted since installing into $USER owned $NODE_PARENT
    

    which puts it into dir defined by above --prefix

    export PATH=${NODE_PARENT}/nodejs/bin:$PATH
    

    define environment variable NODE_PATH so node can find dir for modules otherwise npm install xxx will put newly installed module into current dir :

    export NODE_PATH=${NODE_PARENT}/nodejs/lib/node_modules
    

    when you use syntax : npm install -g some_cool_module the -g for global installs it into dir $NODE_PATH and not your $PWD

    nodejs install gives you npm as well :

    ls -la ${NODE_PARENT}/nodejs/bin
    

    Subsequent modules you install using global flag -g will automagically put their ~binaries~ into above bin dir ... like browserify

    Now put above three export xxx=yyy commands into your ~/.bashrc or some such so your environment is setup

提交回复
热议问题