小编Rob*_*obC的帖子

在npm脚本中运行批处理文件

是否可以以及如何在npm命令中运行批处理脚本?

我有一个角度项目,在package.json文件中,在scripts节下,我想定义一个npm命令来运行批处理脚本.我知道我可以用关键字运行shell脚本,bash例如

"start": "cd mydir && bash ./myscript"
Run Code Online (Sandbox Code Playgroud)

然后我可以npm start在我的项目目录中运行,该目录将更改目录并执行myscript.sh脚本.在npm中运行批处理脚本的等效关键字是什么?

新手在这里.对不起,如果这是一个重复的问题; 也许我没有搜索正确的术语,但我无法找到这个问题的答案.

batch-file npm-scripts

12
推荐指数
1
解决办法
7295
查看次数

tsc 不排除 npm 链接的 node_modules

问题:当使用我的应用程序进行类型检查时,tsc我收到npm linked 模块错误。

这是我的类型检查命令:
"type-check": "tsc --noEmit -p tsconfig.json"

这是我的tsconfig.json

{
    "compilerOptions": {
        "outDir": "./dist/",
        "sourceMap": true,
        "noImplicitAny": false,
        "allowJs": true,
        "module": "commonjs",
        "target": "es6",
        "jsx": "react",
        "esModuleInterop": true,
        "experimentalDecorators": true,
        "skipLibCheck": true
        //"importsNotUsedAsValues": "error"
    },
    "exclude": ["./node_modules/*"] // I've also tried node_modules, /node_modules, node_modules/
}

Run Code Online (Sandbox Code Playgroud)

由于通过 npm 链接连接的我的 node_modules 之一中的类型错误,该命令将失败。

任何从类型检查中排除此模块的方法


编辑:

我也尝试过使用双 globstar ( **) 例如

{
    "compilerOptions": {
        "outDir": "./dist/",
        "sourceMap": true,
        "noImplicitAny": false,
        "allowJs": true,
        "module": "commonjs",
        "target": …
Run Code Online (Sandbox Code Playgroud)

symlink npm typescript

12
推荐指数
1
解决办法
2563
查看次数

如何在ui-router中实现路径别名

我正试图找到一种方法来实现Angular.js中的路由别名ui-router.

假设我有一个带url的状态,article/:articleId我想/articles/some-article-title/article/76554不改变浏览器位置的情况下重定向(内部).

可以这样做ui-router吗?

angularjs angular-ui angular-ui-router

11
推荐指数
1
解决办法
7863
查看次数

找不到插件“proposal-class-properties”。如何解决这个问题?

目前,我正在研究 React 项目。它工作正常。但是现在每当我启动 npm 时。它给了我错误 -

$ react-scripts start
i ?wds?: Project is running at http://192.168.18.45/
i ?wds?: webpack output is served from
i ?wds?: Content not from webpack is served from C:\xampp\htdocs\SkyHi\Staah\staah-instant-site\public
i ?wds?: 404s will fallback to /
Starting the development server...
Failed to compile.

./node_modules/@fortawesome/fontawesome-svg-core/index.es.js
Error: [BABEL] C:\xampp\htdocs\SkyHi\Staah\staah-instant-site\node_modules\@fortawesome\fontawesome-svg-core\index.es.js: Could not find plugin "proposal-class-properties". Ensure there is an entry in ./available-plugins.js for it. (While processing: "C:\\xampp\\htdocs\\SkyHi\\Staah\\staah-instant-site\\node_modules\\babel-preset-react-app\\dependencies.js$0")
    at Array.map (<anonymous>)
    at Generator.next (<anonymous>)
    at Generator.next (<anonymous>)
Run Code Online (Sandbox Code Playgroud)

如何解决这个错误?请帮帮我。我正在使用yarn. …

npm reactjs yarnpkg

11
推荐指数
1
解决办法
1万
查看次数

在纱线启动命令中显示错误表示您的锁文件中似乎不存在此包;尝试进行安装以更新您的分辨率

给出纱线启动命令时显示的错误

错误详情:

Internal Error: confusion@workspace:.: This package doesn't seem to be present in your lockfile; try to make an install to update your resolutions
    at J.getCandidates (C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:2:276872)
    at i.getCandidates (C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:2:266282)
    at C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:2:286432    at C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:57:349928
    at new Promise (<anonymous>)
    at e.exports (C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:57:349910)
    at o (C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:57:349611)
    at C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:57:349684
    at C:\Users\risha\Desktop\Front-End Web Development with React\.yarn\releases\yarn-berry.js:57:349727 …
Run Code Online (Sandbox Code Playgroud)

reactjs package.json yarnpkg

11
推荐指数
2
解决办法
1846
查看次数

无法从 watchpack-chokidar2:fsevents 访问 NPM CI 错误绑定

当我npm ci在 Github Actions 上运行时,出现错误:

Run npm ci
npm ERR! bindings not accessible from watchpack-chokidar2:fsevents

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-09-17T15_18_42_465Z-debug.log
Error: Process completed with exit code 1.
Run Code Online (Sandbox Code Playgroud)

可以是什么?

我的.github/workflows/eslint.yaml

name: ESLint

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Use Node.js
        uses: actions/setup-node@v1
        with:
          node-version: '14.x'
      - run: npm ci
      - run: npm run lint
Run Code Online (Sandbox Code Playgroud)

我的package.json

Run npm ci
npm ERR! …
Run Code Online (Sandbox Code Playgroud)

javascript node.js npm package.json github-actions

11
推荐指数
1
解决办法
2万
查看次数

node_modules/@firebase/firestore/dist/index.d.ts:27:28 中出现错误 - 错误 TS1005:预期为“]”

我尝试将 firebase 包含到我的角度应用程序中,我导入了所有内容,但是当我运行时ng serve出现此错误:

ERROR in node_modules/@firebase/firestore/dist/index.d.ts:27:28 - error TS1005: ']' expected.

27     [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
                              ~~
node_modules/@firebase/firestore/dist/index.d.ts:27:47 - error TS1005: ';' expected.

27     [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
                                                 ~
node_modules/@firebase/firestore/dist/index.d.ts:27:49 - error TS1109: Expression expected.

27     [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
                                                   ~
node_modules/@firebase/firestore/dist/index.d.ts:27:50 - error TS1109: Expression expected.

27     [K in keyof T & string as `${Prefix}.${K}`]+?: T[K];
                                                    ~
node_modules/@firebase/firestore/dist/index.d.ts:28:1 - error TS1128: …
Run Code Online (Sandbox Code Playgroud)

npm firebase typescript firebase-realtime-database angular

11
推荐指数
2
解决办法
6794
查看次数

使用 js 并尝试部署到运行 Linux 的个人服务器时找不到节点模块“node:fs”

Error: Cannot find module 'node:fs'
   at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
   at Function.Module._load (internal/modules/cjs/loader.js:562:25)
   at Module.require (internal/modules/cjs/loader.js:692:17)
   at require (internal/modules/cjs/helpers.js:25:18)
   at Object.<anonymous> (/home/doge/atlas/db-bot/Index.js:1:12)
   at Module._compile (internal/modules/cjs/loader.js:778:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
   at Module.load (internal/modules/cjs/loader.js:653:32)
   at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
   at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Run Code Online (Sandbox Code Playgroud)

我的 package.JSON 文件:

{
  "name": "atlas-db",
  "version": "1.0.0",
  "description": "[REDACTED]",
  "main": "Index.js",
  "scripts": {
    "test": "none"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/[REDACTED]/db-bot.git"
  },
  "keywords": [
    "bot"
  ],
  "author": "[REDACTED]",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/[REDACTED]/db-bot/issues"
  },
  "homepage": "https://github.com/[REDACTED]/db-bot#readme",
  "dependencies": {
    "@discordjs/builders": "^0.13.0",
    "@discordjs/rest": "^0.4.1", …
Run Code Online (Sandbox Code Playgroud)

node.js npm discord.js

11
推荐指数
1
解决办法
4万
查看次数

删除yarn.lock并通过运行yarn install再次生成它是一个好主意吗?

最近我安装了几个 npm 软件包,然后我必须将其删除。现在我不确定yarn.lock文件,并认为它里面可能有一些遗留代码。

删除yarn.lock并通过运行yarn install再次生成它是一个好主意吗?

yarnpkg

10
推荐指数
1
解决办法
5万
查看次数

使用 github 操作缓存 npm 依赖项

我想缓存 npm 依赖项,这样我就不会在每次推送时都执行 npm install ,而是从缓存中加载它。

我认为 github 操作现在支持这个?:如何在 GitHub 操作中缓存步骤?

这里有几个案例

  • 如果package.json更改,这意味着yarn.lockpackage-lock.json更改了 npm install 和 update cache
  • 延长我的上述观点,投稿人可以做的都yarn installnpm install

从上述相同的问题,我将我的 github 操作更改为这样的

name: Tsc compilation test
on: [push, pull_request]
jobs:
  build:
    name: Build
    runs-on: ubuntu-18.04
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Cache NPM dependencies
        uses: actions/cache@v1
        with:
          path: ~/.npm
          key: ${{ runner.OS }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.OS }}-npm-cache-
      - name: Install dependencies
        run: npm …
Run Code Online (Sandbox Code Playgroud)

caching github npm yarnpkg github-actions

10
推荐指数
1
解决办法
2688
查看次数