【问题标题】:node_modules not recognized after npm install on windows在 Windows 上安装 npm 后 node_modules 无法识别
【发布时间】:2016-12-08 19:25:17
【问题描述】:

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

我已将“%AppData%\npm\node_modules”添加到我的系统路径变量中,但它不起作用。

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

"gulp' 不被识别为可操作的内部或外部命令 程序或批处理文件”

所以我假设节点模块没有被识别。如果我尝试手动获取 gulp:

npm install gulp

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,但没有成功。

【问题讨论】:

  • 只是为了澄清:您执行了npm install,并且您的所有依赖项和 devDependencies 都已正确安装但无法识别?

标签: node.js windows npm


【解决方案1】:

好的,我终于解决了这个问题,替换了我的默认路径环境变量:

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

通过

C:\Program Files\nodejs

正如@julianpitt 在this answer 中建议的那样

【讨论】:

    猜你喜欢
    • 2016-03-13
    • 2021-01-11
    • 2012-08-03
    • 2020-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-19
    相关资源
    最近更新 更多