Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
250 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 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...