在Windows上安装npm后无法识别node_modules

时间:2016-08-03 07:43:21

标签: node.js windows npm

当我签出我的项目并在Windows 7上执行npm install时,我的dev_dependencies模块(gulp,electron,...)将被识别。

我已添加"%AppData%\ npm \ node_modules"到我的系统路径变量,但它没有工作。

当我尝试: npm run dist 时,我得到的错误是:

  

"咽'不被认为是可操作的内部或外部命令   程序或批处理文件"

所以我假设节点模块没有被识别。如果我试图手动吞咽:

npm install gulp

问题已经解决了,但不是其他模块。

的package.json

{                                                           
"name": "MyApp",                                 
"description": "Desc",                                 
"version": "0.0.2",                                     
"author": {                                             
    "name": "me",                              
    "email": "me@email.com"                    
},                                                      
"main": "build/main.min.js",                            
"scripts": {                                            
    "start": "electron .",                              
    "pack": "gulp compile && build --dir",              
    "dist": "gulp compile && build -w --x64"            
},                                                      
"devDependencies": {                                    
    "del": "^2.2.0",                                    
    "electron-builder": "^5.22.1",                      
    "electron-packager": "^7.3.0",                      
    "electron-prebuilt": "^1.3.1",                      
    "gulp": "^3.9.1",                                   
    "gulp-bower": "0.0.13",                             
    "gulp-clean-css": "^2.0.6",                         
    "gulp-ng-annotate": "^2.0.0",                       
    "gulp-rename": "^1.2.2",                            
    "gulp-sass": "^2.3.1",                              
    "gulp-scss-lint": "^0.3.9",                         
    "gulp-server-livereload": "^1.7.4",                 
    "gulp-shell": "^0.5.2",                             
    "gulp-tsc": "^1.2.0",                               
    "gulp-uglify": "^1.5.3",                            
    "run-sequence": "^1.1.5",                           
    "typings": "^1.0.4"                                 
},                                                      
"dependencies": {                                       
    "fs-extra": "^0.30.0",                              
    "nedb": "^1.8.0"                                    
},                                                      
"build": {                                              
    "appId": "com.electron.app",                      
    "files": [ "build\/**\/*", "node_modules\/**\/*" ]  
},                                                      
"directories": {                                        
    "buildResources": "tmp-build",                      
    "output": "dist",                                   
    "app": "."                                          
}                                                       
}  

提前致谢!

==编辑==

我也尝试this solution但它还没有奏效。

1 个答案:

答案 0 :(得分:2)

好的,最后我解决了这个问题,取代了我的默认路径环境变量:

  

C:\ Users(您的用户名)\ AppData \ Roaming \ npm

通过

  

C:\ Program Files \ nodejs

@julianpitt在this answer

中建议