【问题标题】:Can't install any packages with Node.js [duplicate]无法使用 Node.js 安装任何软件包 [重复]
【发布时间】:2019-05-28 01:34:03
【问题描述】:

我是 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

谁能给我解释一下这个错误信息?

【问题讨论】:

    标签: node.js cordova ionic-framework package


    【解决方案1】:

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

    1. 检查node、ionic和cordova是否安装正确。

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

      npm 安装

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

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

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

    如果您有任何问题,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-02
      • 1970-01-01
      • 2021-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多