在构建Ionic App时找不到模块'shelljs'

时间:2021-08-12 22:58:18

When I build android platform I receive the error that shelljs module is not found, but that module is globally installed.

当我构建android平台时,我收到了找不到shelljs模块的错误,但该模块是全局安装的。

In fact, the android platform gets build and I can run the project from Android Studio, but... I'd like to be able to emulate from console and I can't do it because this error

事实上,Android平台得到了构建,我可以从Android Studio运行该项目,但是......我希望能够从控制台模拟,我不能这样做,因为这个错误

MacBook-Pro-de-Ruben-5:TransportMe rubdottocom$ sudo ionic build android
Running command: /Users/rubdottocom/Documents/AndroidStudio/TransportMe/hooks/after_prepare/010_add_platform_class.js /Users/rubdottocom/Documents/AndroidStudio/TransportMe
add to body class: platform-android
Running command: /Users/rubdottocom/Documents/AndroidStudio/TransportMe/platforms/android/cordova/build
module.js:338
    throw err;
          ^
Error: Cannot find module 'shelljs'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/rubdottocom/Documents/AndroidStudio/TransportMe/platforms/android/cordova/lib/build.js:24:15)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
ERROR building one of the platforms: Error: /Users/rubdottocom/Documents/AndroidStudio/TransportMe/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/rubdottocom/Documents/AndroidStudio/TransportMe/platforms/android/cordova/build: Command failed with exit code 1
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

Here are the nodeJS modules that I have installed

这是我安装的nodeJS模块

MacBook-Pro-de-Ruben-5:TransportMe rubdottocom$ npm -g ls --depth=0
/usr/local/lib
├── bower@1.4.1
├── chromeos-apk@3.0.0
├── coffee-script@1.6.3
├── cordova@5.1.1
├── gulp@3.9.0
├── ionic@1.6.4
├── less@1.3.1
├── lungo@0.1.5
├── mocha@1.7.0
├── n@2.0.1
├── npm@2.11.3
├── phonegap@5.1.1
├── shelljs@0.5.1
└── volo@0.2.10

1 个解决方案

#1


2  

Finally I solved the problem, removing and adding platform android from the scratch.

最后我解决了这个问题,从头开始删除和添加平台android。

For some reason code was corrupted or missing some reference, I don't know.

由于某种原因代码被破坏或缺少一些参考,我不知道。

Be careful no to lose some important code or file doing this, because will regenerated everything :P

小心不要丢失一些重要的代码或文件这样做,因为将重生一切:P

#1


2  

Finally I solved the problem, removing and adding platform android from the scratch.

最后我解决了这个问题,从头开始删除和添加平台android。

For some reason code was corrupted or missing some reference, I don't know.

由于某种原因代码被破坏或缺少一些参考,我不知道。

Be careful no to lose some important code or file doing this, because will regenerated everything :P

小心不要丢失一些重要的代码或文件这样做,因为将重生一切:P