升级到节点7后无法找到模块'internal / fs' [英] Cannot find module 'internal/fs' after upgrading to node 7

查看:151
本文介绍了升级到节点7后无法找到模块'internal / fs'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近尝试在构建服务器上升级到节点v7.0.0,但在应用程序构建任务失败时开始出现问题bower_concat步骤

 载入bower-concat.js任务...错误
错误:找不到模块'internal / fs'

我们安装了什么:




  • 节点 v7.0.0(通过 yum安装 nodesource存储库

  • npm 4.0.1

  • 使用 grunt (如果这是相关的)

  • grunt-bower-concat 0.6.0


grunt构建任务配置:

  grunt.registerTask(
'build :prod',[
'clean:prod',
'copy:prod',
'replace',
bower_concat',
'ngtemplates',
'concat',
'uglify',
'cssmin',
'injector:prod',
' copy:cssfix',
'copy:dist',
'bowercopy:dist',
'bowercopy:fonts',
'template:setProdVersion'
]
);

以及 bower_concat 任务:

  bower_concat:{
all:{
dest:'<%= app.build%> / bower.js',
cssDest:'<%= app.build%> /bower.css',
依赖关系:{
'bootstrap':'jquery'
},
mainFiles:{
angular-app-modules:[
app / dist / angular-app-modules.min.js,
app / dist /angular-app-modules.min.css

}
}
},

请注意,它在v6.9.0的节点上没有任何问题。



什么可能导致问题?我们可以在不降级到节点v6的情况下解决问题吗?




还有这个相关问题,但截至目前,这些信息对我们的案例没有帮助。

解决方案

首先,以管理员身份打开控制台(或者在终端中打开 sudo ,如果它是Linux的话)和:

  npm cache clean 

对于npm 5和更高版本

  npm cache clean --force 






编辑:

对于Windows,您可能无法清理缓存,因此您可以通过删除以下所有文件夹内容手动删除缓存:

  C:\ Users \< USER-NAME> \AppData\Roaming\\\
pm-cache



感谢superwf,这种情况可能会发生一些,但我从来没有这样做(可能是因为我的安全级别最低?)。



结束编辑。




然后返回到正常控制台(不是管理员或root),返回到package.json所在的项目目录,然后删除 node_modules 文件夹,将其完全删除,然后再次将节点模块安装到您的项目文件夹中:

  npm install 

在安装模块之前,您可能需要更新模块。我建议这样做,但如果模块中有任何主要的版本更改,必须小心重大更改
此模块 npm-check-updates 可以帮助您检查最新版本和更新它们。



另外,您可能还需要安装最新的全局模块,并通过以下方式检查更新:

  ncu -g 

  npm过期-g 



<如果你仍然陷入困境,你可能需要删除全局的 node_modules 文件夹并重新安装你想要的东西。





编辑 即使在清理过程中也会出现相同的问题,实际上,您可以使用
个人而言,我开始使用 yarn 来代替传统的 npm i ,我可以保证它更快,并节省你的时间,并从npm头痛你的头。


We've recently tried to upgrade to node v7.0.0 on our build server, but started to have issues during the application build task failing on the "bower_concat" step:

Loading "bower-concat.js" tasks...ERROR
Error: Cannot find module 'internal/fs'

What we have installed:

  • node v7.0.0 (installed via yum "nodesource" repository)
  • npm 4.0.1
  • using grunt (if this is relevant)
  • grunt-bower-concat 0.6.0

The grunt build task configuration:

grunt.registerTask(
    'build:prod', [
        'clean:prod',
        'copy:prod',
        'replace',
        'bower_concat',
        'ngtemplates',
        'concat',
        'uglify',
        'cssmin',
        'injector:prod',
        'copy:cssfix',
        'copy:dist',
        'bowercopy:dist',
        'bowercopy:fonts',
        'template:setProdVersion'
    ]
);

And the grunt bower_concat task:

bower_concat: {
    all: {
        dest: '<%= app.build %>/bower.js',
        cssDest: '<%= app.build %>/bower.css',
        dependencies: {
            'bootstrap': 'jquery'
        },
        mainFiles: {
            "angular-app-modules": [
                "app/dist/angular-app-modules.min.js",
                "app/dist/angular-app-modules.min.css"
            ]
        }
    }
}, 

Note that it works without any problems on node v6.9.0.

What can be causing the issue? Can we workaround the problem without downgrading to node v6?


There is also this relevant issue, but, as of now, the information there does not help in our case.

解决方案

First, open the console as administrator (or in the terminal with sudo if it is a Linux) and:

npm cache clean

For npm 5 and later

npm cache clean --force


Edit:

For windows you might fail to clean the cache, so you can remove the cache manually by deleting all the following folder content:

C:\Users\<USER-NAME>\AppData\Roaming\npm-cache

Thanks "superwf", this case might happen for some, but I never had to do this (maybe because of my lowest security level?!).

End Edit.


Then go back to the normal console (not administrator or root), return to your project directory where the package.json is located, and then delete the node_modules folder from your project, remove it completely, and then install node modules again inside your project folder:

npm install

You might need to update your modules before installing modules again. I recommend this, but be careful of breaking changes if there are any major version changes in your modules. This module npm-check-updates can help you to check the latest version and update them.

Also, you maybe need to install the latest global modules as well, check updates by:

ncu -g

or

npm outdated -g

If you're still stuck, you might need to remove the global node_modules folder and reinstall what you want again.


Edit:

Yarn option: Some people ended with the same issues even with the cleanup procedures, actually you save your time a lot using Yarn. Personally, I started to use yarn instead of traditional npm i, I can guarantee it is faster, and save your time, and your head from npm headaches.

这篇关于升级到节点7后无法找到模块'internal / fs'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆