Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
269 views
in Technique[技术] by (71.8m points)

node.js - Set directory for NPM

I'm working with git-bash on win 7. I want to develop an ember project and I am working on a thumb drive. I have installed node on my E drive and added the path to the env vars.

 $ npm install -g ember-cli
  C:UsersmeAppDataRoaming
pmember -> C:UsersmeAppDataRoaming
pm
ode_modulesember-cliinember
  C:UsersmeAppDataRoaming
pm? -> C:UsersmeAppDataRoaming
pm
ode_modulesember-cliinember
  + [email protected]
  updated 553 packages in 89.25s

  $ which npm
  /e/nodejs/npm

  $ which node
  /e/nodejs/node

  $ ember build
  sh.exe": ember: command not found

So I think whats happening is that npm is installing the packages on the c drive. I need to set a folder on my e drive, to make this portable. How can I do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can set this by configuring the npm prefix setting:

npm config set prefix e:somepathone

This could be done globally or on a per-project basis by modifying the project's .npmrc file.

Go to the folder with your package.json and run npm config ls to see your effective npm config.

See the npm docs for global settings


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...