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条回答
走好不送
2楼-- · 2019-01-31 16:45

if you are using n to update node versions and all npm commands are failing with this message that means you have latest node but an older npm version.

so in this case do the following, (may need sudo)

n 4.7 npm install npm -g n latest

it will go back to node 4.7 and then install latest npm using it. after than it will come back to latest npm version. (replace latest with whatever version you actually want)

查看更多
做自己的国王
3楼-- · 2019-01-31 16:46

1) sudo npm cache clean -f

2) sudo npm install -g n

3) sudo n stable

Just Three Steps :)

查看更多
相关推荐>>
4楼-- · 2019-01-31 16:47

None of the answers worked for me.

In the end I reinstalled node and ionic and that did the trick:

npm cache clean -f
npm install npm -g

npm uninstall node
npm install node -g

My system information before fixing the issue:

Cordova CLI: 7.0.1
Ionic CLI Version: 1.7.11         <-- way too old
Ionic App Lib Version: 0.6.5
ios-deploy version: 1.9.1
ios-sim version: 5.0.4
OS: Mac OS X El Capitan
Node Version: v8.0.0
Xcode version: Xcode 8.3.3 Build version 8E3004b
查看更多
▲ chillily
5楼-- · 2019-01-31 16:53

If using mac

cd ~/.nvm/versions

and remove node folder

查看更多
做个烂人
6楼-- · 2019-01-31 16:55

In my case clearing the cache did not work. What did work was deleting the node_modules/npm folder within my nodejs install location. Then running the nodejs installer again and using the 'repair' option (note: this is for Windows).

From what I could gather in the npm debug log, it looked like my old version of npm wasn't completely removed before the new version was installed. So there were some lingering deprecated modules in the folder where npm was installed.

查看更多
可以哭但决不认输i
7楼-- · 2019-01-31 16:55

I'm on Windows 8.1 x64 , upgrading from v6 to v7. I got this issue on global installation I have many packages installed already, but every time I ran npm command, whether npm install, npm list,npm update etc. always return the same error

This step works for me:

  1. Clean npm cache manually by deleting npm-cache folder located at

C:\Users[usrname]\AppData\Roaming\

  1. Remove/rename npm folder in my NodeJS installation directory. In this case , I rename npm folder to npm-- in

C:\Program Files\nodejs\node_modules

  1. Re-install NodeJS v7

Everything works fine then

查看更多
登录 后发表回答