Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未找到模块:错误:Can';t解决';财政司司长';在里面_Javascript_Angular - Fatal编程技术网

Javascript 未找到模块:错误:Can';t解决';财政司司长';在里面

Javascript 未找到模块:错误:Can';t解决';财政司司长';在里面,javascript,angular,Javascript,Angular,好的,我把角度从6升到了8。但我还是会出错 我在互联网上找到了一个对很多用户都有帮助的解决方案。但在这种情况下,这对我没有帮助 因此,我的package.json文件如下所示: { "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", "baseUrl": "src&quo

好的,我把角度从6升到了8。但我还是会出错

我在互联网上找到了一个对很多用户都有帮助的解决方案。但在这种情况下,这对我没有帮助

因此,我的package.json文件如下所示:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  },
   "angularCompilerOptions": {
     "enableIvy": false
   }
}
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
    extend(config, {}) {
        config.node = {
            fs: 'empty'
        }
    }
},
{
“名称”:“vital10前端”,
“版本”:“0.55.0”,
“许可证”:“未经许可证”,
“脚本”:{
“ng”:“ng”,
“开始”:“ng发球”,
“hmr”:“ng serve——配置hmr”,
“构建”:“ng构建”,
“构建:生产”:“npm运行sass:prod&&npm运行vit10prod”,
“构建:acc”:“npm运行sass:prod和npm运行vit10acc”,
“构建:测试”:“npm运行sass:prod&&npm运行vit10test”,
“构建:开发”:“npm运行sass:prod&&npm运行vit10dev”,
“测试”:“ng测试”,
“测试:覆盖”:“ng测试——代码覆盖率”,
“皮棉”:“ng皮棉”,
“e2e”:“ng e2e”,
“本地”:“ng服务-c本地”,
“分析包”:“webpack bundle analyzer dist/stats.json”,
“postinstall”:“节点修补程序webpack.js”,
“sass:watch”:“sass--watch sass:src\\assets”,
“sass:prod”:“sass--update-f--style compressed--sourcemap=none-sass:src\\assets”,
“vit10dev”:“ng build--prod-c vit10dev”,
“vit10test”:“ng构建--prod-c vit10test”,
“vit10acc”:“ng构建--prod-c vit10acc”,
“vit10prod”:“ng构建—prod-c生产”
},
“私人”:没错,
“依赖项”:{
“@angular/animations”:“^8.1.2”,
“@angular/cdk”:“^7.3.7”,
“@angular/common”:“^8.1.2”,
“@angular/compiler”:“^8.1.2”,
“@angular/core”:“^8.1.2”,
“@angular/forms”:“^8.1.2”,
“@angular/http”:“^7.2.15”,
“@角度/平台浏览器”:“^8.1.2”,
“@angular/platform browser dynamic”:“^8.1.2”,
“@angular/platform server”:“^8.1.2”,
“@angular/router”:“^8.1.2”,
“@types/chart.js”:“^2.7.54”,
“缓冲区”:“^5.2.1”,
“chart.js”:“^2.7.2”,
“核心js”:“^2.5.7”,
“事件”:“^3.0.0”,
“fs”:“0.0.1-安全性”,
“茉莉花”:“^3.1.0”,
“ng2图表”:“^1.6.0”,
“ng2德古拉”:“^2.1.1”,
“ng2 pdf查看器”:“^5.0.1”,
“节点sass”:“^4.11.0”,
“oidc客户端”:“^1.5.1”,
“路径”:“^0.12.7”,
“pdfjs区”:“^2.0.489”,
“rxjs”:“^6.5.2”,
“rxjs compat”:“^6.5.2”,
“流”:“0.0.2”,
“计时器”:“^0.1.1”,
“web动画js”:“^2.3.1”,
“zone.js”:“^0.9.1”
},
“依赖性”:{
“@angular devkit/build angular”:“^0.801.2”,
“@angular/cli”:“^8.1.2”,
“@angular/compiler cli”:“^8.1.2”,
“@angular/language service”:“^8.1.2”,
“@angularclass/hmr”:“^2.1.3”,
“@compodoc/compodoc”:“^1.1.10”,
“@types/jasmine”:“^3.3.14”,
“@types/node”:“^12.6.8”,
“柴”:“^4.1.2”,
“codelyzer”:“^5.1.0”,
“将csv转换为json”:“0.0.13”,
“黄瓜”:“^4.2.1”,
“Cumber html reporter”:“^5.0.0”,
“黄瓜少年”:“^1.7.1”,
“快速静态”:“^1.2.5”,
“茉莉花芯”:“^3.4.0”,
“茉莉花记者”:“^2.3.1”,
“jasmine spec reporter”:“^4.2.1”,
“因果报应”:“^4.2.0”,
“karma chrome启动器”:“^3.0.0”,
“karma cli”:“^2.0.0”,
“因果报应报道伊斯坦布尔记者”:“^1.2.1”,
“karma html reporter”:“^0.2.7”,
“因果报应茉莉”:“^2.0.1”,
“karma jasmine html reporter”:“^1.4.2”,
“karma junit reporter”:“^1.2.0”,
“karma teamcity reporter”:“^1.1.0”,
“时刻”:“^2.22.1”,
“更漂亮”:“1.13.4”,
“量角器”:“^5.4.2”,
“量角器美丽的记者”:“^1.2.1”,
“量角器框架”:“^5.0.0”,
“木偶演员”:“^1.14.0”,
“请求”:“^2.87.0”,
“本机请求承诺”:“^1.0.5”,
“ts节点”:“^3.3.0”,
“tslint”:“^5.18.0”,
“tslint角度”:“^1.1.2”,
“类型脚本”:“3.4.5”,
“网页包包分析器”:“^3.3.2”,
“xlsx”:“^0.12.13”
},
“浏览器”:{
“fs”:错误,
“路径”:错误,
“os”:错误,
“加密”:假,
“流”:假,
“http”:false,
“tls”:错误,
“zlib”:错,
“https”:false,
“网络”:错误
}
}
我的b
tsconfig.json
文件如下所示:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  },
   "angularCompilerOptions": {
     "enableIvy": false
   }
}
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
    extend(config, {}) {
        config.node = {
            fs: 'empty'
        }
    }
},
但我仍然会发现这些错误:

ERROR in ./node_modules/resolve/lib/async.js
Module not found: Error: Can't resolve 'fs' in 'C:\Source\nien\vital10-frontend\node_modules\resolve\lib'
ERROR in ./node_modules/resolve/lib/sync.js
Module not found: Error: Can't resolve 'fs' in 'C:\Source\nien\vital10-frontend\node_modules\resolve\lib'
ERROR in ./node_modules/resolve/lib/node-modules-paths.js
Module not found: Error: Can't resolve 'fs' in 'C:\Source\nien\vital10-frontend\node_modules\resolve\lib'
ERROR in ./node_modules/tslint/lib/utils.js
Module not found: Error: Can't resolve 'fs' in 'C:\Source\nien\vital10-frontend\node_modules\tslint\lib'
我找到了一个可能的解决方案,您必须在其中一个node_模块中进行一些配置。但我认为这不是一个好的解决办法。因为如果您删除所有导入,然后再次安装导入,您的配置将失效

多谢各位

好的,我取下了

 "fs": "0.0.1-security",
我删除了所有的packe(node_模块)并安装了npm

但现在我明白了:

(node:13880) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added. Use emitter.setMaxListeners() to increase limit
Binary found at C:\Source\nien\vital10-frontend\node_modules\node-sass\vendor\win32-x64-64\binding.node
Testing binary
Binary is fine

> vital10-frontend@0.55.0 postinstall C:\Source\nien\vital10-frontend
> node patch-webpack.js

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'C:\Source\nien\vital10-frontend\patch-webpack.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vital10-frontend@0.55.0 postinstall: `node patch-webpack.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vital10-frontend@0.55.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\nien\AppData\Roaming\npm-cache\_logs\2019-07-23T10_25_46_184Z-debug.log
PS C:\Source\nien\vital10-frontend>
现在,我的package.json文件如下所示:

{
  "name": "vital10-frontend",
  "version": "0.55.0",
  "license": "Unlicensed",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "hmr": "ng serve --configuration hmr",
    "build": "ng build",
    "build:prod": "npm run sass:prod && npm run vit10prod",
    "build:acc": "npm run sass:prod && npm run vit10acc",
    "build:test": "npm run sass:prod && npm run vit10test",
    "build:dev": "npm run sass:prod && npm run vit10dev",
    "test": "ng test",
    "test:cover": "ng test --code-coverage",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "local": "ng serve -c local",
    "analyze-bundle": "webpack-bundle-analyzer dist/stats.json",
    "postinstall": "node patch-webpack.js",
    "sass:watch": "sass --watch sass:src\\assets",
    "sass:prod": "sass --update -f --style compressed --sourcemap=none sass:src\\assets",
    "vit10dev": "ng build --prod -c vit10dev",
    "vit10test": "ng build --prod -c vit10test",
    "vit10acc": "ng build --prod -c vit10acc",
    "vit10prod": "ng build --prod -c production"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.1.2",
    "@angular/cdk": "^7.3.7",
    "@angular/common": "^8.1.2",
    "@angular/compiler": "^8.1.2",
    "@angular/core": "^8.1.2",
    "@angular/forms": "^8.1.2",
    "@angular/http": "^7.2.15",
    "@angular/platform-browser": "^8.1.2",
    "@angular/platform-browser-dynamic": "^8.1.2",
    "@angular/platform-server": "^8.1.2",
    "@angular/router": "^8.1.2",
    "@types/chart.js": "^2.7.54",
    "buffer": "^5.2.1",
    "chart.js": "^2.7.2",
    "core-js": "^2.5.7",
    "events": "^3.0.0",
    "jasmine": "^3.1.0",
    "ng2-charts": "^1.6.0",
    "ng2-dragula": "^2.1.1",
    "ng2-pdf-viewer": "^5.0.1",
    "node-sass": "^4.11.0",
    "oidc-client": "^1.5.1",
    "path": "^0.12.7",
    "pdfjs-dist": "^2.0.489",
    "rxjs": "^6.5.2",
    "rxjs-compat": "^6.5.2",
    "stream": "0.0.2",
    "timers": "^0.1.1",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.801.2",
    "@angular/cli": "^8.1.2",
    "@angular/compiler-cli": "^8.1.2",
    "@angular/language-service": "^8.1.2",
    "@angularclass/hmr": "^2.1.3",
    "@compodoc/compodoc": "^1.1.10",
    "@types/jasmine": "^3.3.14",
    "@types/node": "^12.6.8",
    "chai": "^4.1.2",
    "codelyzer": "^5.1.0",
    "convert-csv-to-json": "0.0.13",
    "cucumber": "^4.2.1",
    "cucumber-html-reporter": "^5.0.0",
    "cucumber-junit": "^1.7.1",
    "express-static": "^1.2.5",
    "jasmine-core": "^3.4.0",
    "jasmine-reporters": "^2.3.1",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^4.2.0",
    "karma-chrome-launcher": "^3.0.0",
    "karma-cli": "^2.0.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-html-reporter": "^0.2.7",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "karma-junit-reporter": "^1.2.0",
    "karma-teamcity-reporter": "^1.1.0",
    "moment": "^2.22.1",
    "prettier": "1.13.4",
    "protractor": "^5.4.2",
    "protractor-beautiful-reporter": "^1.2.1",
    "protractor-cucumber-framework": "^5.0.0",
    "puppeteer": "^1.14.0",
    "request": "^2.87.0",
    "request-promise-native": "^1.0.5",
    "ts-node": "^3.3.0",
    "tslint": "^5.18.0",
    "tslint-angular": "^1.1.2",
    "typescript": "3.4.5",
    "webpack-bundle-analyzer": "^3.3.2",
    "xlsx": "^0.12.13"
  },
  "browser": {
    "fs": false,
    "path": false,
    "os": false,
    "crypto": false,
    "stream": false,
    "http": false,
    "tls": false,
    "zlib": false,
    "https": false,
    "net": false
  }
}
仍然会出现以下错误:

(node:15956) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added. Use emitter.setMaxListeners() to increase limit
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'C:\Source\nien\vital10-frontend\patch-webpack.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vital10-frontend@0.55.0 postinstall: `node patch-webpack.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vital10-frontend@0.55.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\nien\AppData\Roaming\npm-cache\_logs\2019-07-23T10_59_04_891Z-debug.log
PS C:\Source\nien\vital10-frontend>
我仍然有三个错误:

ERROR in ./node_modules/resolve/lib/async.js
Module not found: Error: Can't resolve 'fs' in 'C:\Source\nien\vital10-frontend\node_modules\resolve\lib'
ERROR in ./node_modules/resolve/lib/sync.js
Module not found: Error: Can't resolve 'fs' in 'C:\Source\nien\vital10-frontend\node_modules\resolve\lib'
ERROR in ./node_modules/tslint/lib/utils.js
Module not found: Error: Can't resolve 'fs' in 'C:\Source\nien\vital10-frontend\node_modules\tslint\lib'
i 「wdm」: Failed to compile.

你能试试这些步骤吗

  • 删除节点模块
  • 删除
    包锁.json
  • package.json中删除
    “fs”:“0.0.1-security”
  • npm安装--保存

  • 错误是因为
    angular cli
    不支持节点中的模块,如“fs”和“path”。()

    将以下内容添加到“package.json”文件中

    我希望这对某人有帮助


    谢谢。

    只需将
    {node:'empty'}
    添加到您的
    webpack.config
    文件中。

    对我来说,解决方案是将此添加到webpack配置中:

    config.node={
    财政司司长:‘空置’,
    }
    
    如果使用NuxtJS,另一个解决方案是:

    //生成配置:https://go.nuxtjs.dev/config-build
    建造:{
    扩展(配置,{}){
    config.node={
    财政司司长:空置
    }
    }
    },
    
    如果您使用NextJS(未经测试,请确认它在注释中有效):

    webpack:(config,{buildId,dev,isServer,defaultLoaders,webpack})=>{
    config.node={
    财政司司长:空置
    }
    返回配置
    },
    
    在其他情况下,请参阅Anjana Silva post。编辑package.json文件就可以完成这项工作

    我正在使用Nuxt.JS 对我有效的方法是使用@thisismyname解决方案,并将其添加到nuxt.config.js,如下所示:

    {
      "compileOnSave": false,
      "compilerOptions": {
        "outDir": "./dist/out-tsc",
        "baseUrl": "src",
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "target": "es5",
        "typeRoots": [
          "node_modules/@types"
        ],
        "lib": [
          "es2016",
          "dom"
        ]
      },
       "angularCompilerOptions": {
         "enableIvy": false
       }
    }
    
    // Build Configuration: https://go.nuxtjs.dev/config-build
    build: {
        extend(config, {}) {
            config.node = {
                fs: 'empty'
            }
        }
    },
    

    我得到了同样的错误,但这是由于我的错误,因为我使用axios进行网络请求,但是