无法使用Node.js安装任何软件包

时间:2019-05-27 08:40:57

标签: node.js cordova ionic-framework package

我是Ionic,Cordova和Node.js的绝对新手。

Node.js存在以下问题:

我从一个由ionic和cordova创建的同事那里得到一个项目。该应用程序本身也正在运行,对于特殊客户,我们已对其设计进行了调整。我的想法是很快就完成了。我将我在GIT中的分支更改为相应的项目,并希望做到这一点。不幸的是,我收到了以前项目中没有的无数错误消息和警告。

我卸载了Node.js并完全重新安装了它,不幸的是没有任何变化。我无法卸载或安装任何软件包。我总是收到这条永远长的错误消息,但我不知道到底是什么问题。卸载Ionic和Cordova也不起作用,同样的错误消息。下面是我的Node.js,Ionic和Cordova版本以及错误消息的开头和结尾的列表。

Console:gitproject user$ git branch
* development
  master
Console:gitproject user$ ionic cordova build
? What platform would you like to build (android, ios): ios
> ionic-app-scripts build --target cordova --platform ios
[08:44:43]  ionic-app-scripts 3.2.3 
[08:44:43]  build dev started ... 
[08:44:43]  clean started ... 
[08:44:43]  clean finished in 24 ms 
[08:44:43]  copy started ... 
[08:44:43]  deeplinks started ... 
[08:44:44]  deeplinks finished in 593 ms 
[08:44:44]  transpile started ... 
[08:44:56]  typescript: src/app/app.component.ts, line: 34 
            Cannot find name 'Globalization'. 

      L33:            private translate: TranslateService,
      L34:            private globalization: Globalization) {
      L35:  platform.ready().then(() => {

[08:44:56]  ionic-app-script task: "build" 
[08:44:56]  Error: Failed to transpile program 
Error: Failed to transpile program
    at new BuildError (/path/to/project/gitproject/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
    at /path/to/project/gitproject/node_modules/@ionic/app-scripts/dist/transpile.js:159:20
    at new Promise (<anonymous>)
    at transpileWorker (/path/to/project/gitproject/node_modules/@ionic/app-scripts/dist/transpile.js:107:12)
    at Object.transpile (/path/to/project/gitproject/node_modules/@ionic/app-scripts/dist/transpile.js:64:12)
    at /path/to/project/gitproject/node_modules/@ionic/app-scripts/dist/build.js:109:82
[ERROR] An error occurred while running subprocess ionic-app-scripts.

        ionic-app-scripts build --target cordova --platform ios exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.
Console:gitproject user$ ionic cordova plugin add cordova-plugin-globalization
> cordova plugin add cordova-plugin-globalization --save
Installing "cordova-plugin-globalization" for ios
Unable to load PlatformApi from platform. Error: Cannot find module 'unorm'
Require stack:
- /path/to/project/gitproject/platforms/ios/cordova/Api.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/platforms.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/plugman.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/cordova-lib.js
- /usr/local/lib/node_modules/cordova/src/help.js
- /usr/local/lib/node_modules/cordova/src/cli.js
- /usr/local/lib/node_modules/cordova/bin/cordova
Failed to install 'cordova-plugin-globalization': Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('The platform "ios" does not appear to be a valid ' +
  'cordova platform. It is missing API.js. ios not ' +
  'supported.')
    at CordovaEventEmitter.emit (events.js:185:17)
    at CordovaEventEmitter.emit (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/events.js:69:22)
    at Object.getPlatformApiFunction (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js:384:20)
    at Object.getPlatformApi (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/platforms.js:55:32)
    at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:580:29)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:349:28
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
Unhandled error. ('The platform "ios" does not appear to be a valid ' +
  'cordova platform. It is missing API.js. ios not ' +
  'supported.')
Console:gitproject user$ npm install @ionic-native/globalization

> fsevents@1.2.4 install /path/to/project/gitproject/node_modules/fsevents
> node install

node-pre-gyp WARN Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.4/fse-v1.2.4-node-v72-darwin-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for fsevents@1.2.4 and node@12.2.0 (node-v72 ABI, unknown) (falling back to source compile with node-gyp) 

...
...
...
...

10 warnings and 8 errors generated.
make: *** [Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/path/to/project/gitproject/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:200:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/bin/node" "/path/to/project/gitproject/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /path/to/project/gitproject/node_modules/node-sass
gyp ERR! node -v v12.3.1
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok 
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.9.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!     /path/to/user/folder/.npm/_logs/2019-05-27T08_04_02_672Z-debug.log

这是上述错误日志的版本

2653 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
2654 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 install: `node install`
2654 warn optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
2655 verbose optional SKIPPING OPTIONAL DEPENDENCY:
2655 verbose optional Failed at the fsevents@1.2.4 install script.
2655 verbose optional SKIPPING OPTIONAL DEPENDENCY: This is probably not a problem with npm. There is likely additional logging output above.
2656 verbose stack Error: node-sass@4.9.0 postinstall: `node scripts/build.js`
2656 verbose stack Exit status 1
2656 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
2656 verbose stack     at EventEmitter.emit (events.js:200:13)
2656 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
2656 verbose stack     at ChildProcess.emit (events.js:200:13)
2656 verbose stack     at maybeClose (internal/child_process.js:1021:16)
2656 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
2657 verbose pkgid node-sass@4.9.0
2658 verbose cwd /Users/premox/Documents/projects/gitproject
2659 verbose Darwin 18.6.0
2660 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "uninstall" "sass"
2661 verbose node v12.3.1
2662 verbose npm  v6.9.0
2663 error code ELIFECYCLE
2664 error errno 1
2665 error node-sass@4.9.0 postinstall: `node scripts/build.js`
2665 error Exit status 1
2666 error Failed at the node-sass@4.9.0 postinstall script.
2666 error This is probably not a problem with npm. There is likely additional logging output above.
2667 verbose exit [ 1, true ]

Console:gitproject user$ node -v
v12.3.1
Console:gitproject user$ npm -v
6.9.0

有人可以向我解释此错误消息吗?

2 个答案:

答案 0 :(得分:1)

删除文件夹node_modules\@ionic\app-scripts并执行以下命令

npm install @ionic/app-scripts@latest --save-dev

编辑1:

尝试该错误,它将起作用。

 npm uninstall -g cordova
 npm install -g cordova@latest

答案 1 :(得分:0)

为了正确设置项目,您可以做几件事。

  1. 检查节点,离子和科尔多瓦安装是否正确。

  2. 完全删除节点模块文件夹,然后运行以下命令:-

    npm install

这将在项目中安装所有依赖项。

  1. 如果上述方法不起作用,则可以尝试执行Ashok提到的相同步骤来解决:-

    npm install @ ionic / app-scripts @ latest --save-dev

如有任何疑问,请告诉我。