ENOENT: node_modules\jquery\dist\jquery.min.js'没有这样的文件或目录

Posted

技术标签:

【中文标题】ENOENT: node_modules\\jquery\\dist\\jquery.min.js\'没有这样的文件或目录【英文标题】:ENOENT: no such file or directory for node_modules\jquery\dist\jquery.min.js'ENOENT: node_modules\jquery\dist\jquery.min.js'没有这样的文件或目录 【发布时间】:2018-10-26 06:36:16 【问题描述】:

我不确定我做错了什么:

我正在关注教程here,但我不断收到以下错误:

ENOENT:没有这样的文件或目录,打开 'C:\Users\andrewkp\Documents\VSCode\Projects\node_modules\jquery\dist\jquery.min.js' 错误:ENOENT:没有这样的文件或目录,打开 'C:\Users\andrewkp\Documents\VSCode\Projects\node_modules\jquery\dist\jquery.min.js'

这是我的 angular.json 文件。


  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": 
    "MyProjectName": 
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": ,
      "architect": 
        "build": 
          "builder": "@angular-devkit/build-angular:browser",
          "options": 
            "outputPath": "dist/MyProjectName",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css",
              "../node_modules/bootstrap/dist/css/bootstrap.min.css"
            ],
            "scripts": [
              "../node_modules/jquery/dist/jquery.min.js",
              "../node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
          ,
          "configurations": 
            "production": 
              "fileReplacements": [
                
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            
          
        ,
        "serve": 
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": 
            "browserTarget": "MyProjectName:build"
          ,
          "configurations": 
            "production": 
              "browserTarget": "MyProjectName:build:production"
            
          
        ,
        "extract-i18n": 
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": 
            "browserTarget": "MyProjectName:build"
          
        ,
        "test": 
          "builder": "@angular-devkit/build-angular:karma",
          "options": 
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [
              "src/styles.css",
              "../node_modules/bootstrap/dist/css/bootstrap.min.css"
            ],
            "scripts": [
              "../node_modules/jquery/dist/jquery.min.js",
              "../node_modules/bootstrap/dist/js/bootstrap.min.js"
            ],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          
        ,
        "lint": 
          "builder": "@angular-devkit/build-angular:tslint",
          "options": 
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          
        
      
    ,
    "MyProjectName-e2e": 
      "root": "e2e/",
      "projectType": "application",
      "architect": 
        "e2e": 
          "builder": "@angular-devkit/build-angular:protractor",
          "options": 
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "MyProjectName:serve"
          
        ,
        "lint": 
          "builder": "@angular-devkit/build-angular:tslint",
          "options": 
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          
        
      
    
  ,
  "defaultProject": "MyProjectName"

【问题讨论】:

【参考方案1】:

仔细检查我的错误后:

C:\Users\andrewkp\Documents\VSCode\Projects\node_modules\jquery\dist\jquery.min.js'

我注意到我正在导航到很远的地方,因为我可以在上面看到它试图读取的路径是完全错误的,根本不包括我的项目名称。

解决方法是改变:

"styles": [
   "src/styles.css",
   "../node_modules/bootstrap/dist/css/bootstrap.min.css"
 ],
 "scripts": [
   "../node_modules/jquery/dist/jquery.min.js",
   "../node_modules/bootstrap/dist/js/bootstrap.min.js"
 ]

收件人:

"styles": [
   "src/styles.css",
   "node_modules/bootstrap/dist/css/bootstrap.min.css"
 ],
 "scripts": [
   "node_modules/jquery/dist/jquery.min.js",
   "node_modules/bootstrap/dist/js/bootstrap.min.js"
 ]

【讨论】:

完全一样的事情发生在我身上,在我找到你的帖子之前很难发现 太棒了!谢谢! 在包含引导程序时遇到了类似的问题 它对我不起作用,我检查了 jquery.min.js 是否在该文件夹中,确实如此,我也更改了路线,但一切都保持不变

以上是关于ENOENT: node_modules\jquery\dist\jquery.min.js'没有这样的文件或目录的主要内容,如果未能解决你的问题,请参考以下文章

npm ERR! code ENOENT npm ERR! syscall open npm ERR! errno -4058 npm ERR! enoent ENOENT: no such file

Jenkins 并行阶段 - enoent ENOENT:没有这样的文件或目录

npm ERR! enoent ENOENT: no such file or directory, rename

Heroku 创建命令产生“ENOENT”错误 [关闭]

Gitbook PDF 转换错误:ENOENT

ENOENT:没有这样的文件或目录。?