Cannot find module 'internal/fs' after upg

2019-01-31 16:41发布

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.

17条回答
\"骚年 ilove
2楼-- · 2019-01-31 17:06

You need to install the last version of bower

> npm install -g bower

Apparently, npm > 4.0 do not use internal/fs module.

查看更多
放荡不羁爱自由
3楼-- · 2019-01-31 17:06

On Win10 this worked for me: (adjust to relevant node version and username)

  • Uninstall node (via node-v7.8.0-x64.msi)
  • Remove the folders 'npm' and 'npm-cache' in 'C:\Users\yourusername\AppData\Roaming
  • Install node again (via node-v7.8.0-x64.msi)
查看更多
Ridiculous、
4楼-- · 2019-01-31 17:08

In my case clearing the cache did not work. Below was my initial state and how I resolved this:

node -v v7.4.0
npm -v 4.0.5

I resolved by doing the following and using n manager:

$ sudo n 6.9.1
$ sudo npm -g install npm@next
$ sudo n stable

Hope this helps!

查看更多
Ridiculous、
5楼-- · 2019-01-31 17:08

I solve this by installing NVM to manage Node

https://github.com/creationix/nvm#installation

after install NVM, reinstall node

nvm install node
查看更多
6楼-- · 2019-01-31 17:10

In linux,when I update to node 7, this happened, "npm cache clean" does work.

In windows, npm cache clean also generate

Error: Cannot find module 'internal/fs'

Just remove

C:\Users[username]\AppData\Roaming\npm

C:\Users[username]\AppData\Roaming\npm-cache

solved

查看更多
登录 后发表回答